Project Part 3
13.01.2024
In the realm of linen manufacturing, the production of high-quality linen garments is a complex process. Linen, derived from the fibers of the flax plant, possesses unique properties such as exceptional coolness and freshness in hot weather. The manufacturing process, though laborious, is crucial in delivering premium linen products to consumers. This project focuses on the implementation of quality control measures using image analysis to identify defects in linen production.
Manual Inspection Era: In the earlier stages of linen manufacturing, process monitoring heavily relied on manual inspection. Skilled workers visually examined linen materials for defects and irregularities. While this approach had its merits, it was subjective, labor-intensive, and less suited for large-scale production.
Automation and Image Processing: With technological advancements, there has been a notable shift towards automating visual inspection using image processing techniques. Researchers and industry professionals recognized the need for sophisticated image acquisition systems and efficient procedures for texture analysis in materials production, including textiles like linen.
Texture Analysis: Texture analysis emerged as a crucial aspect of process monitoring in linen manufacturing. Researchers explored the application of image processing algorithms to analyze the texture of linen fabrics. These techniques aimed to identify patterns, defects, and irregularities in the material.
Statistical Process Control (SPC): The integration of Statistical Process Control (SPC) principles into linen manufacturing gained attention. Traditional control charts, widely used in manufacturing for process monitoring, were adapted to monitor the quality of linen production. However, challenges arose due to the spatial nature of image data, prompting the exploration of advanced statistical methods.
Challenges and Opportunities: Challenges in process monitoring for linen manufacturing include the complex and heterogeneous nature of linen materials, the need for real-time defect detection, and adapting statistical methods to handle image data. The literature explores these challenges and identifies opportunities for future research.
Advanced Machine Learning Techniques: More recently, the literature has seen an increased exploration of advanced machine learning techniques for process monitoring in textiles. This includes the application of algorithms for pattern recognition, anomaly detection, and predictive maintenance in linen manufacturing.
Integration of Industry 4.0 Technologies: Industry 4.0 concepts, such as the Internet of Things (IoT) and smart manufacturing, are being explored to enhance process monitoring in linen manufacturing. Real-time data collection, connectivity, and analytics play a role in optimizing production processes.
A Baseline Defect Detection Approach from a Statistical Data Analysis Perspective:
First we have put pixel values in a matrix and plotted the pixel values
#Part1.1
library(jpeg)
library(MASS)
library(mixtools)
## mixtools package, version 2.0.0, Released 2022-12-04
## This package is based upon work supported by the National Science Foundation under Grant No. SES-0518772 and the Chan Zuckerberg Initiative: Essential Open Source Software for Science (Grant No. 2020-255193).
# Read the color image
img <- readJPEG("~/Desktop/Dersler/IE423/outputimage.jpg")
# Part 1.1
# Flatten the 2D matrix to a vector
pixel_values <- as.matrix(img)
head(pixel_values)
## [,1] [,2] [,3] [,4] [,5] [,6] [,7]
## [1,] 0.7490196 0.7490196 0.6980392 0.6117647 0.5294118 0.4274510 0.3490196
## [2,] 0.7882353 0.7764706 0.7215686 0.6666667 0.6196078 0.5294118 0.4352941
## [3,] 0.8117647 0.8078431 0.7607843 0.7098039 0.6666667 0.5921569 0.5137255
## [4,] 0.8078431 0.8235294 0.7843137 0.7098039 0.6313725 0.5490196 0.5019608
## [5,] 0.8196078 0.8313725 0.7843137 0.6941176 0.6000000 0.5058824 0.4470588
## [6,] 0.8156863 0.8039216 0.7411765 0.6705882 0.6117647 0.5215686 0.4274510
## [,8] [,9] [,10] [,11] [,12] [,13] [,14]
## [1,] 0.3294118 0.3450980 0.3490196 0.3647059 0.3921569 0.4352941 0.5098039
## [2,] 0.3921569 0.3450980 0.3450980 0.3686275 0.4235294 0.4941176 0.5725490
## [3,] 0.4823529 0.4274510 0.3960784 0.3882353 0.4392157 0.5333333 0.6313725
## [4,] 0.5137255 0.4784314 0.4431373 0.4274510 0.4745098 0.5686275 0.6666667
## [5,] 0.4509804 0.4235294 0.4274510 0.4627451 0.5372549 0.6274510 0.7019608
## [6,] 0.3921569 0.3960784 0.4196078 0.4705882 0.5450980 0.6196078 0.6980392
## [,15] [,16] [,17] [,18] [,19] [,20] [,21]
## [1,] 0.6078431 0.6862745 0.7411765 0.7058824 0.6509804 0.6392157 0.5411765
## [2,] 0.6470588 0.6980392 0.7254902 0.7294118 0.7254902 0.7411765 0.6392157
## [3,] 0.7098039 0.7607843 0.8352941 0.8156863 0.7764706 0.7490196 0.6274510
## [4,] 0.7490196 0.7960784 0.8431373 0.8352941 0.8039216 0.7764706 0.6352941
## [5,] 0.7647059 0.8039216 0.8509804 0.8470588 0.8117647 0.7843137 0.6470588
## [6,] 0.7725490 0.8274510 0.8862745 0.8705882 0.8196078 0.7843137 0.6509804
## [,22] [,23] [,24] [,25] [,26] [,27] [,28]
## [1,] 0.5058824 0.4274510 0.3764706 0.3764706 0.3450980 0.3215686 0.3372549
## [2,] 0.5686275 0.4509804 0.3686275 0.3490196 0.3294118 0.3215686 0.3647059
## [3,] 0.5647059 0.4745098 0.4196078 0.3764706 0.3607843 0.3607843 0.4078431
## [4,] 0.5568627 0.4549020 0.4000000 0.3333333 0.3254902 0.3450980 0.4039216
## [5,] 0.5764706 0.4823529 0.4352941 0.4039216 0.3882353 0.3960784 0.4431373
## [6,] 0.5921569 0.5137255 0.4745098 0.4313725 0.4000000 0.3843137 0.4117647
## [,29] [,30] [,31] [,32] [,33] [,34] [,35]
## [1,] 0.3882353 0.4666667 0.5529412 0.6156863 0.6705882 0.6196078 0.5529412
## [2,] 0.4470588 0.5568627 0.6666667 0.7450980 0.7372549 0.7372549 0.7176471
## [3,] 0.4901961 0.5921569 0.6941176 0.7647059 0.7686275 0.8039216 0.8117647
## [4,] 0.4941176 0.6000000 0.6980392 0.7686275 0.8078431 0.8313725 0.7960784
## [5,] 0.5294118 0.6352941 0.7411765 0.8117647 0.7882353 0.7960784 0.7450980
## [6,] 0.4862745 0.5882353 0.6980392 0.7725490 0.7803922 0.7803922 0.7450980
## [,36] [,37] [,38] [,39] [,40] [,41] [,42]
## [1,] 0.4980392 0.4509804 0.4156863 0.4078431 0.4156863 0.4235294 0.4039216
## [2,] 0.6705882 0.5960784 0.5176471 0.4509804 0.4117647 0.4431373 0.4274510
## [3,] 0.7529412 0.6627451 0.5725490 0.4862745 0.4274510 0.3803922 0.3725490
## [4,] 0.6862745 0.5686275 0.4901961 0.4313725 0.3843137 0.4039216 0.3803922
## [5,] 0.6313725 0.5372549 0.4980392 0.4823529 0.4588235 0.4392157 0.4039216
## [6,] 0.6745098 0.6117647 0.5803922 0.5607843 0.5411765 0.4980392 0.4627451
## [,43] [,44] [,45] [,46] [,47] [,48] [,49]
## [1,] 0.4196078 0.4509804 0.4901961 0.5764706 0.6666667 0.7019608 0.7333333
## [2,] 0.4588235 0.5176471 0.5803922 0.6862745 0.7803922 0.8117647 0.8549020
## [3,] 0.4156863 0.4980392 0.5960784 0.7215686 0.8196078 0.8470588 0.8549020
## [4,] 0.4117647 0.4901961 0.5921569 0.7098039 0.7960784 0.8117647 0.7843137
## [5,] 0.4078431 0.4666667 0.5450980 0.6470588 0.7137255 0.7176471 0.7921569
## [6,] 0.4745098 0.5372549 0.6196078 0.7176471 0.7803922 0.7803922 0.7803922
## [,50] [,51] [,52] [,53] [,54] [,55] [,56]
## [1,] 0.7372549 0.6588235 0.5882353 0.5372549 0.4980392 0.4745098 0.4078431
## [2,] 0.8705882 0.8156863 0.7607843 0.6823529 0.5921569 0.5294118 0.4470588
## [3,] 0.8745098 0.8431373 0.8196078 0.7450980 0.6313725 0.5607843 0.4901961
## [4,] 0.7882353 0.7568627 0.7450980 0.6823529 0.5921569 0.5607843 0.5294118
## [5,] 0.7803922 0.7254902 0.6941176 0.6352941 0.5607843 0.5529412 0.5372549
## [6,] 0.7725490 0.7019608 0.6588235 0.6000000 0.5411765 0.5372549 0.5098039
## [,57] [,58] [,59] [,60] [,61] [,62] [,63]
## [1,] 0.4000000 0.3607843 0.3215686 0.3764706 0.5098039 0.6196078 0.6745098
## [2,] 0.4000000 0.3764706 0.3607843 0.4392157 0.5921569 0.7058824 0.7686275
## [3,] 0.4666667 0.4392157 0.4117647 0.4784314 0.6196078 0.7254902 0.7803922
## [4,] 0.4745098 0.4431373 0.4117647 0.4705882 0.6117647 0.7254902 0.7960784
## [5,] 0.5098039 0.4784314 0.4509804 0.5019608 0.6235294 0.7176471 0.7686275
## [6,] 0.5294118 0.5058824 0.4823529 0.5294118 0.6313725 0.6901961 0.7137255
## [,64] [,65] [,66] [,67] [,68] [,69] [,70]
## [1,] 0.7215686 0.7215686 0.7529412 0.7450980 0.6509804 0.4862745 0.4235294
## [2,] 0.8156863 0.8392157 0.8313725 0.7882353 0.6980392 0.5490196 0.4941176
## [3,] 0.8235294 0.8588235 0.8392157 0.8078431 0.7647059 0.6431373 0.5725490
## [4,] 0.8509804 0.8509804 0.8156863 0.7843137 0.7450980 0.6117647 0.5176471
## [5,] 0.8117647 0.7843137 0.7450980 0.7019608 0.6509804 0.5294118 0.4666667
## [6,] 0.7372549 0.7254902 0.7137255 0.6901961 0.6470588 0.5333333 0.4980392
## [,71] [,72] [,73] [,74] [,75] [,76] [,77]
## [1,] 0.3098039 0.2941176 0.2823529 0.3372549 0.4000000 0.4470588 0.5058824
## [2,] 0.3843137 0.3803922 0.4588235 0.4705882 0.4666667 0.4549020 0.4823529
## [3,] 0.4431373 0.4274510 0.3921569 0.3921569 0.3843137 0.3843137 0.4392157
## [4,] 0.3686275 0.3529412 0.3607843 0.3686275 0.3843137 0.4117647 0.4823529
## [5,] 0.3647059 0.3843137 0.3921569 0.4000000 0.4117647 0.4431373 0.5215686
## [6,] 0.4196078 0.4431373 0.3843137 0.3725490 0.3647059 0.3882353 0.4705882
## [,78] [,79] [,80] [,81] [,82] [,83] [,84]
## [1,] 0.6078431 0.7294118 0.8078431 0.7960784 0.7647059 0.6980392 0.5450980
## [2,] 0.5764706 0.6980392 0.7843137 0.8235294 0.7960784 0.7254902 0.5764706
## [3,] 0.5529412 0.6862745 0.7647059 0.7921569 0.8078431 0.8039216 0.6980392
## [4,] 0.5843137 0.6823529 0.7333333 0.7686275 0.7843137 0.7725490 0.6666667
## [5,] 0.6196078 0.7058824 0.7450980 0.7647059 0.7764706 0.7725490 0.6784314
## [6,] 0.5921569 0.7019608 0.7568627 0.7764706 0.7921569 0.7921569 0.7098039
## [,85] [,86] [,87] [,88] [,89] [,90] [,91]
## [1,] 0.4666667 0.3529412 0.3372549 0.3411765 0.3960784 0.3843137 0.3764706
## [2,] 0.5058824 0.4078431 0.4078431 0.4274510 0.3450980 0.3450980 0.3764706
## [3,] 0.6274510 0.4823529 0.4235294 0.4039216 0.3647059 0.3843137 0.4470588
## [4,] 0.5960784 0.4588235 0.4078431 0.3960784 0.4156863 0.4039216 0.4274510
## [5,] 0.6196078 0.4901961 0.4392157 0.4196078 0.3843137 0.4039216 0.4588235
## [6,] 0.6666667 0.5333333 0.4627451 0.4274510 0.3725490 0.4392157 0.5568627
## [,92] [,93] [,94] [,95] [,96] [,97] [,98]
## [1,] 0.3882353 0.4274510 0.4784314 0.5254902 0.5529412 0.5411765 0.5882353
## [2,] 0.4588235 0.5764706 0.6901961 0.7647059 0.7960784 0.7960784 0.7882353
## [3,] 0.5647059 0.6941176 0.7764706 0.7882353 0.7725490 0.7372549 0.7333333
## [4,] 0.5137255 0.6392157 0.7411765 0.7921569 0.8000000 0.8196078 0.7843137
## [5,] 0.5607843 0.6784314 0.7725490 0.8196078 0.8274510 0.8078431 0.7764706
## [6,] 0.6862745 0.7882353 0.8235294 0.8000000 0.7725490 0.7647059 0.7607843
## [,99] [,100] [,101] [,102] [,103] [,104] [,105]
## [1,] 0.5372549 0.4745098 0.4078431 0.3411765 0.3333333 0.3215686 0.3607843
## [2,] 0.6745098 0.5607843 0.4549020 0.3607843 0.3490196 0.3411765 0.3215686
## [3,] 0.6666667 0.6039216 0.5019608 0.3882353 0.3529412 0.3215686 0.3803922
## [4,] 0.7058824 0.6274510 0.5019608 0.3921569 0.3843137 0.3647059 0.3215686
## [5,] 0.7098039 0.6196078 0.4588235 0.3372549 0.3333333 0.2980392 0.2784314
## [6,] 0.7411765 0.6862745 0.5372549 0.4431373 0.4313725 0.3607843 0.3686275
## [,106] [,107] [,108] [,109] [,110] [,111] [,112]
## [1,] 0.3921569 0.3568627 0.3215686 0.2862745 0.3098039 0.4235294 0.4823529
## [2,] 0.3529412 0.3333333 0.3450980 0.3803922 0.4666667 0.6235294 0.6980392
## [3,] 0.3843137 0.3490196 0.3764706 0.4470588 0.5647059 0.7215686 0.7921569
## [4,] 0.3490196 0.3607843 0.4470588 0.5607843 0.6705882 0.7843137 0.8039216
## [5,] 0.3372549 0.4000000 0.5333333 0.6705882 0.7568627 0.8117647 0.7882353
## [6,] 0.3960784 0.4078431 0.4980392 0.6156863 0.7058824 0.7764706 0.7647059
## [,113] [,114] [,115] [,116] [,117] [,118] [,119]
## [1,] 0.5294118 0.6039216 0.6039216 0.5215686 0.5098039 0.4627451 0.3686275
## [2,] 0.7725490 0.8313725 0.8313725 0.7450980 0.6862745 0.5764706 0.4313725
## [3,] 0.7843137 0.8117647 0.8313725 0.8078431 0.7882353 0.6823529 0.5176471
## [4,] 0.8078431 0.7882353 0.8039216 0.8235294 0.8352941 0.7372549 0.5686275
## [5,] 0.7725490 0.7450980 0.7764706 0.7843137 0.7490196 0.6313725 0.4745098
## [6,] 0.7764706 0.7764706 0.8274510 0.8078431 0.7176471 0.5921569 0.4784314
## [,120] [,121] [,122] [,123] [,124] [,125] [,126]
## [1,] 0.3882353 0.3686275 0.3686275 0.3725490 0.3843137 0.3921569 0.4039216
## [2,] 0.4274510 0.4117647 0.4039216 0.3960784 0.4078431 0.4745098 0.5843137
## [3,] 0.4980392 0.3764706 0.4078431 0.4392157 0.4823529 0.5647059 0.6745098
## [4,] 0.5254902 0.4705882 0.4705882 0.4470588 0.4392157 0.5215686 0.6588235
## [5,] 0.4392157 0.4352941 0.4117647 0.3607843 0.3529412 0.4666667 0.6588235
## [6,] 0.4627451 0.4235294 0.4235294 0.4313725 0.4862745 0.6274510 0.7843137
## [,127] [,128] [,129] [,130] [,131] [,132] [,133]
## [1,] 0.4196078 0.4313725 0.4431373 0.4862745 0.4666667 0.4470588 0.3921569
## [2,] 0.6862745 0.7411765 0.7333333 0.7529412 0.7019608 0.6431373 0.5529412
## [3,] 0.7372549 0.7450980 0.7764706 0.7921569 0.7215686 0.6196078 0.4901961
## [4,] 0.7490196 0.7607843 0.8000000 0.7960784 0.7058824 0.6078431 0.4941176
## [5,] 0.7921569 0.8313725 0.8666667 0.8392157 0.7333333 0.6431373 0.5411765
## [6,] 0.8705882 0.8784314 0.8980392 0.9058824 0.8156863 0.6980392 0.5568627
## [,134] [,135] [,136] [,137] [,138] [,139] [,140]
## [1,] 0.3490196 0.3607843 0.3490196 0.3764706 0.3803922 0.4235294 0.4588235
## [2,] 0.4509804 0.4000000 0.3411765 0.3450980 0.3568627 0.3960784 0.4745098
## [3,] 0.3843137 0.3686275 0.3490196 0.3647059 0.3764706 0.3647059 0.4235294
## [4,] 0.4156863 0.4196078 0.4078431 0.3333333 0.3725490 0.3529412 0.4117647
## [5,] 0.4470588 0.4039216 0.3450980 0.3098039 0.3647059 0.3647059 0.4509804
## [6,] 0.4549020 0.4509804 0.4431373 0.3882353 0.4039216 0.3921569 0.4745098
## [,141] [,142] [,143] [,144] [,145] [,146] [,147]
## [1,] 0.4549020 0.4941176 0.6078431 0.7058824 0.7607843 0.7137255 0.6745098
## [2,] 0.5725490 0.6509804 0.7215686 0.7764706 0.7960784 0.7725490 0.7607843
## [3,] 0.5843137 0.7019608 0.7490196 0.7882353 0.8470588 0.8431373 0.8588235
## [4,] 0.6156863 0.7607843 0.8039216 0.8431373 0.8431373 0.8392157 0.8431373
## [5,] 0.6705882 0.8078431 0.8039216 0.7960784 0.8000000 0.7843137 0.7490196
## [6,] 0.6705882 0.8000000 0.7960784 0.7647059 0.7882353 0.7725490 0.7098039
## [,148] [,149] [,150] [,151] [,152] [,153] [,154]
## [1,] 0.5843137 0.3529412 0.3294118 0.3490196 0.3098039 0.3098039 0.3568627
## [2,] 0.6862745 0.4392157 0.3764706 0.3647059 0.3294118 0.3411765 0.3450980
## [3,] 0.8078431 0.5568627 0.4588235 0.4235294 0.3960784 0.3176471 0.3294118
## [4,] 0.8000000 0.5725490 0.4705882 0.4235294 0.4117647 0.4156863 0.4196078
## [5,] 0.6980392 0.5215686 0.4588235 0.4274510 0.4274510 0.4549020 0.4509804
## [6,] 0.6549020 0.5333333 0.5333333 0.5333333 0.5450980 0.4705882 0.4313725
## [,155] [,156] [,157] [,158] [,159] [,160] [,161]
## [1,] 0.3450980 0.3058824 0.2784314 0.3647059 0.5294118 0.5764706 0.6392157
## [2,] 0.3450980 0.3803922 0.3843137 0.4509804 0.6196078 0.7137255 0.7764706
## [3,] 0.3450980 0.4000000 0.4235294 0.4901961 0.6549020 0.7333333 0.8000000
## [4,] 0.3607843 0.3098039 0.3176471 0.4666667 0.6862745 0.7686275 0.8549020
## [5,] 0.3725490 0.3019608 0.2941176 0.4392157 0.6627451 0.7529412 0.8078431
## [6,] 0.3725490 0.3647059 0.3686275 0.4549020 0.6588235 0.7725490 0.8000000
## [,162] [,163] [,164] [,165] [,166] [,167] [,168]
## [1,] 0.6470588 0.6549020 0.6392157 0.5725490 0.4705882 0.4000000 0.3803922
## [2,] 0.7764706 0.7568627 0.7215686 0.6470588 0.5058824 0.3921569 0.3647059
## [3,] 0.8392157 0.8431373 0.8156863 0.7294118 0.5411765 0.3960784 0.3882353
## [4,] 0.8862745 0.8509804 0.7647059 0.6392157 0.4588235 0.3764706 0.4352941
## [5,] 0.8274510 0.8039216 0.7333333 0.6196078 0.4745098 0.4000000 0.4274510
## [6,] 0.7803922 0.7607843 0.7176471 0.6392157 0.5450980 0.4627451 0.4039216
## [,169] [,170] [,171] [,172] [,173] [,174] [,175]
## [1,] 0.3607843 0.2862745 0.2745098 0.2784314 0.3411765 0.4470588 0.4823529
## [2,] 0.3215686 0.3098039 0.3450980 0.3529412 0.4235294 0.5843137 0.7019608
## [3,] 0.3921569 0.3686275 0.3647059 0.3568627 0.4666667 0.6705882 0.7843137
## [4,] 0.4666667 0.4352941 0.4000000 0.3803922 0.5215686 0.7333333 0.8156863
## [5,] 0.5372549 0.5372549 0.4941176 0.4352941 0.5254902 0.6705882 0.7058824
## [6,] 0.3647059 0.3764706 0.3686275 0.3921569 0.5725490 0.7411765 0.7607843
## [,176] [,177] [,178] [,179] [,180] [,181] [,182]
## [1,] 0.4862745 0.5098039 0.5490196 0.5372549 0.5529412 0.4901961 0.3372549
## [2,] 0.7764706 0.7490196 0.7137255 0.6000000 0.5372549 0.4862745 0.4117647
## [3,] 0.8470588 0.8862745 0.8431373 0.6980392 0.5490196 0.4392157 0.4156863
## [4,] 0.8509804 0.8392157 0.8156863 0.7098039 0.5647059 0.4235294 0.3921569
## [5,] 0.7411765 0.7803922 0.7411765 0.6549020 0.5686275 0.4588235 0.4000000
## [6,] 0.7921569 0.7450980 0.7333333 0.6549020 0.5725490 0.4627451 0.3803922
## [,183] [,184] [,185] [,186] [,187] [,188] [,189]
## [1,] 0.3058824 0.3647059 0.4745098 0.4627451 0.4470588 0.4549020 0.4352941
## [2,] 0.3921569 0.3803922 0.3019608 0.3607843 0.3607843 0.3921569 0.5098039
## [3,] 0.4431373 0.3921569 0.3450980 0.3098039 0.2313725 0.3333333 0.5686275
## [4,] 0.4156863 0.3333333 0.3137255 0.3411765 0.3333333 0.5058824 0.7490196
## [5,] 0.3686275 0.2549020 0.2980392 0.4470588 0.4627451 0.5294118 0.7019608
## [6,] 0.3529412 0.2862745 0.2352941 0.3607843 0.4078431 0.5568627 0.7529412
## [,190] [,191] [,192] [,193] [,194] [,195] [,196]
## [1,] 0.4862745 0.6039216 0.6196078 0.6039216 0.6588235 0.6117647 0.3843137
## [2,] 0.6862745 0.8156863 0.7882353 0.8392157 0.7333333 0.6352941 0.5098039
## [3,] 0.7450980 0.8352941 0.8470588 0.7725490 0.6980392 0.6392157 0.5333333
## [4,] 0.8000000 0.7843137 0.8000000 0.8627451 0.7372549 0.5725490 0.3960784
## [5,] 0.7686275 0.7960784 0.8392157 0.7686275 0.7058824 0.6274510 0.5254902
## [6,] 0.7725490 0.7411765 0.7568627 0.8156863 0.7803922 0.6392157 0.4823529
## [,197] [,198] [,199] [,200] [,201] [,202] [,203]
## [1,] 0.3450980 0.3803922 0.3098039 0.3960784 0.3764706 0.3803922 0.3843137
## [2,] 0.4862745 0.4313725 0.3058824 0.3764706 0.5019608 0.4235294 0.3137255
## [3,] 0.5058824 0.4901961 0.3921569 0.4078431 0.3764706 0.3843137 0.3725490
## [4,] 0.3686275 0.4352941 0.4039216 0.3764706 0.4392157 0.4117647 0.3843137
## [5,] 0.4627451 0.4392157 0.4235294 0.4509804 0.4784314 0.4196078 0.4274510
## [6,] 0.4431373 0.4941176 0.5490196 0.5960784 0.3647059 0.3137255 0.3372549
## [,204] [,205] [,206] [,207] [,208] [,209] [,210]
## [1,] 0.4274510 0.4941176 0.5098039 0.5098039 0.5294118 0.6117647 0.4431373
## [2,] 0.2941176 0.4156863 0.5686275 0.6862745 0.7647059 0.7764706 0.7215686
## [3,] 0.4078431 0.5176471 0.6235294 0.6980392 0.7450980 0.8235294 0.7960784
## [4,] 0.4352941 0.5490196 0.6392157 0.7019608 0.7647059 0.7921569 0.8274510
## [5,] 0.5960784 0.7921569 0.8392157 0.7843137 0.7568627 0.7686275 0.7686275
## [6,] 0.5176471 0.7294118 0.7960784 0.7725490 0.7647059 0.8196078 0.7490196
## [,211] [,212] [,213] [,214] [,215] [,216] [,217]
## [1,] 0.3960784 0.4627451 0.4588235 0.4196078 0.3764706 0.3137255 0.3019608
## [2,] 0.6313725 0.5372549 0.4392157 0.3529412 0.3294118 0.3686275 0.3254902
## [3,] 0.7372549 0.6941176 0.5803922 0.3529412 0.2745098 0.4156863 0.3764706
## [4,] 0.7372549 0.5843137 0.4980392 0.4431373 0.3843137 0.3529412 0.4862745
## [5,] 0.8039216 0.7647059 0.6156863 0.5098039 0.5058824 0.5215686 0.4823529
## [6,] 0.6431373 0.4980392 0.4470588 0.5647059 0.5843137 0.4235294 0.4039216
## [,218] [,219] [,220] [,221] [,222] [,223] [,224]
## [1,] 0.2784314 0.2823529 0.2980392 0.2941176 0.3882353 0.3333333 0.3490196
## [2,] 0.2666667 0.3215686 0.4117647 0.4509804 0.6156863 0.6549020 0.6745098
## [3,] 0.3843137 0.3803922 0.4784314 0.6352941 0.7372549 0.7058824 0.7803922
## [4,] 0.3803922 0.4235294 0.5764706 0.6823529 0.7882353 0.8156863 0.7686275
## [5,] 0.4274510 0.3019608 0.3725490 0.6470588 0.7529412 0.7764706 0.8627451
## [6,] 0.3529412 0.3921569 0.5568627 0.7568627 0.8156863 0.8196078 0.7254902
## [,225] [,226] [,227] [,228] [,229] [,230] [,231]
## [1,] 0.3372549 0.3294118 0.2980392 0.4588235 0.4313725 0.3725490 0.3529412
## [2,] 0.4980392 0.3843137 0.3254902 0.4235294 0.4823529 0.4431373 0.5098039
## [3,] 0.7098039 0.4980392 0.3803922 0.4627451 0.1960784 0.2862745 0.4627451
## [4,] 0.7568627 0.6039216 0.4941176 0.4196078 0.4274510 0.3568627 0.3921569
## [5,] 0.7725490 0.6000000 0.4039216 0.4196078 0.2705882 0.4039216 0.3647059
## [6,] 0.7019608 0.6509804 0.5294118 0.3803922 0.4313725 0.3764706 0.2941176
## [,232] [,233] [,234] [,235] [,236] [,237] [,238]
## [1,] 0.3764706 0.4196078 0.3843137 0.4274510 0.2627451 0.3058824 0.3568627
## [2,] 0.5450980 0.4235294 0.2862745 0.2666667 0.4117647 0.4352941 0.5372549
## [3,] 0.5333333 0.4274510 0.2392157 0.3960784 0.4313725 0.5098039 0.7372549
## [4,] 0.4000000 0.4000000 0.4823529 0.3450980 0.5921569 0.8039216 0.7411765
## [5,] 0.3254902 0.4392157 0.3529412 0.4117647 0.6588235 0.7882353 0.8078431
## [6,] 0.3176471 0.3686275 0.2823529 0.4117647 0.6862745 0.7607843 0.7764706
## [,239] [,240] [,241] [,242] [,243] [,244] [,245]
## [1,] 0.3254902 0.4078431 0.3215686 0.3960784 0.3607843 0.2980392 0.4588235
## [2,] 0.7529412 0.5725490 0.7490196 0.5803922 0.5098039 0.3843137 0.4274510
## [3,] 0.7176471 0.8823529 0.8431373 0.7843137 0.5725490 0.4039216 0.5137255
## [4,] 0.7176471 0.7960784 0.7921569 0.6588235 0.6627451 0.4274510 0.3921569
## [5,] 0.6980392 0.7490196 0.7686275 0.6941176 0.5725490 0.4980392 0.4862745
## [6,] 0.7843137 0.7647059 0.7843137 0.7490196 0.6431373 0.4039216 0.4941176
## [,246] [,247] [,248] [,249] [,250] [,251] [,252]
## [1,] 0.4117647 0.5372549 0.4470588 0.4784314 0.4470588 0.3372549 0.4117647
## [2,] 0.4823529 0.2901961 0.3215686 0.4000000 0.4117647 0.3843137 0.3490196
## [3,] 0.3176471 0.4666667 0.3490196 0.3725490 0.3529412 0.2823529 0.4941176
## [4,] 0.3843137 0.3019608 0.4509804 0.3960784 0.3647059 0.3529412 0.4549020
## [5,] 0.3372549 0.3529412 0.4078431 0.5098039 0.3411765 0.3137255 0.5333333
## [6,] 0.3764706 0.4941176 0.4274510 0.3764706 0.4117647 0.3607843 0.5647059
## [,253] [,254] [,255] [,256] [,257] [,258] [,259]
## [1,] 0.4862745 0.7058824 0.5215686 0.4392157 0.4000000 0.3686275 0.3843137
## [2,] 0.5568627 0.8235294 0.8117647 0.7098039 0.7294118 0.6862745 0.4588235
## [3,] 0.6000000 0.8549020 0.8156863 0.9098039 0.7882353 0.7803922 0.6588235
## [4,] 0.6196078 0.7450980 0.7647059 0.7960784 0.8000000 0.7529412 0.7137255
## [5,] 0.7019608 0.6705882 0.7019608 0.8392157 0.8823529 0.8392157 0.6196078
## [6,] 0.6901961 0.8549020 0.8274510 0.8196078 0.8156863 0.6745098 0.6000000
## [,260] [,261] [,262] [,263] [,264] [,265] [,266]
## [1,] 0.3215686 0.3607843 0.2980392 0.2823529 0.3568627 0.2666667 0.3490196
## [2,] 0.3764706 0.4588235 0.3333333 0.3137255 0.3058824 0.3411765 0.3137255
## [3,] 0.3411765 0.4156863 0.4352941 0.2705882 0.4549020 0.2431373 0.4470588
## [4,] 0.5294118 0.4039216 0.4588235 0.4196078 0.2313725 0.3254902 0.3725490
## [5,] 0.4039216 0.3647059 0.3960784 0.3568627 0.3333333 0.2196078 0.4862745
## [6,] 0.5019608 0.4313725 0.4313725 0.3372549 0.4352941 0.4156863 0.3450980
## [,267] [,268] [,269] [,270] [,271] [,272] [,273]
## [1,] 0.2784314 0.3411765 0.4156863 0.3529412 0.3647059 0.3607843 0.4549020
## [2,] 0.3647059 0.3294118 0.4392157 0.6117647 0.6078431 0.6862745 0.6823529
## [3,] 0.2117647 0.4156863 0.6862745 0.6470588 0.8196078 0.8156863 0.8039216
## [4,] 0.5098039 0.6588235 0.8156863 0.8862745 0.8392157 0.8392157 0.7686275
## [5,] 0.4666667 0.6313725 0.8588235 0.8196078 0.8000000 0.7764706 0.7411765
## [6,] 0.3803922 0.6235294 0.7803922 0.8000000 0.8352941 0.8078431 0.8039216
## [,274] [,275] [,276] [,277] [,278] [,279] [,280]
## [1,] 0.4862745 0.2666667 0.4156863 0.2823529 0.3333333 0.2705882 0.2980392
## [2,] 0.5843137 0.5725490 0.4705882 0.4117647 0.3098039 0.3568627 0.4392157
## [3,] 0.6313725 0.5333333 0.5215686 0.2980392 0.3921569 0.2470588 0.3882353
## [4,] 0.4745098 0.5450980 0.3372549 0.4156863 0.3568627 0.3725490 0.3372549
## [5,] 0.6039216 0.5450980 0.4313725 0.3450980 0.3960784 0.4000000 0.3725490
## [6,] 0.7294118 0.5843137 0.4392157 0.3294118 0.3607843 0.4078431 0.3647059
## [,281] [,282] [,283] [,284] [,285] [,286] [,287]
## [1,] 0.4862745 0.3450980 0.4156863 0.2588235 0.3215686 0.3960784 0.2392157
## [2,] 0.4549020 0.4666667 0.4117647 0.5764706 0.6117647 0.4980392 0.6156863
## [3,] 0.3294118 0.1882353 0.3960784 0.5254902 0.6745098 0.8705882 0.7960784
## [4,] 0.4235294 0.4392157 0.4980392 0.6705882 0.7333333 0.8000000 0.8862745
## [5,] 0.4039216 0.3176471 0.4862745 0.6509804 0.7372549 0.7725490 0.7450980
## [6,] 0.4039216 0.4000000 0.4431373 0.6745098 0.8039216 0.7568627 0.7725490
## [,288] [,289] [,290] [,291] [,292] [,293] [,294]
## [1,] 0.5803922 0.3058824 0.3803922 0.2862745 0.2941176 0.3803922 0.2470588
## [2,] 0.6980392 0.6588235 0.4313725 0.4431373 0.3921569 0.3568627 0.5215686
## [3,] 0.7607843 0.7098039 0.5607843 0.3647059 0.4117647 0.5333333 0.3607843
## [4,] 0.7333333 0.7568627 0.6313725 0.5215686 0.3960784 0.4117647 0.3882353
## [5,] 0.8274510 0.7333333 0.6117647 0.4666667 0.3411765 0.3725490 0.3490196
## [6,] 0.7647059 0.6627451 0.6117647 0.3764706 0.4117647 0.4941176 0.2352941
## [,295] [,296] [,297] [,298] [,299] [,300] [,301]
## [1,] 0.3490196 0.2509804 0.2117647 0.2588235 0.2627451 0.4392157 0.2235294
## [2,] 0.4196078 0.4274510 0.2941176 0.2705882 0.2862745 0.2666667 0.4823529
## [3,] 0.5019608 0.2313725 0.2823529 0.4196078 0.4392157 0.4862745 0.7215686
## [4,] 0.3019608 0.4313725 0.4823529 0.4745098 0.4941176 0.5372549 0.7529412
## [5,] 0.2901961 0.4431373 0.4274510 0.3215686 0.3647059 0.6627451 0.8666667
## [6,] 0.4313725 0.2352941 0.3450980 0.3450980 0.3098039 0.6666667 0.8078431
## [,302] [,303] [,304] [,305] [,306] [,307] [,308]
## [1,] 0.3960784 0.2901961 0.2627451 0.3725490 0.2784314 0.4784314 0.3764706
## [2,] 0.3882353 0.4313725 0.5843137 0.5686275 0.4431373 0.3137255 0.4666667
## [3,] 0.6274510 0.5607843 0.7019608 0.7764706 0.7882353 0.7215686 0.2000000
## [4,] 0.7490196 0.7803922 0.7568627 0.7529412 0.7176471 0.5568627 0.4039216
## [5,] 0.8823529 0.8274510 0.7019608 0.7686275 0.7803922 0.5803922 0.3450980
## [6,] 0.9137255 0.8549020 0.8392157 0.7686275 0.6941176 0.6549020 0.3294118
## [,309] [,310] [,311] [,312] [,313] [,314] [,315]
## [1,] 0.5254902 0.4156863 0.1215686 0.3725490 0.1254902 0.3921569 0.3176471
## [2,] 0.3058824 0.2901961 0.4431373 0.1843137 0.4666667 0.2901961 0.3098039
## [3,] 0.3019608 0.4078431 0.3529412 0.4470588 0.2980392 0.4235294 0.3764706
## [4,] 0.3490196 0.3137255 0.3333333 0.3921569 0.4196078 0.3921569 0.3098039
## [5,] 0.3058824 0.3372549 0.3568627 0.3686275 0.5333333 0.4196078 0.2627451
## [6,] 0.4862745 0.3764706 0.2039216 0.4078431 0.2823529 0.5882353 0.3137255
## [,316] [,317] [,318] [,319] [,320] [,321] [,322]
## [1,] 0.2705882 0.3725490 0.2235294 0.4431373 0.4627451 0.5019608 0.6784314
## [2,] 0.3411765 0.2235294 0.5176471 0.5372549 0.6588235 0.7568627 0.6901961
## [3,] 0.2901961 0.4901961 0.6823529 0.7686275 0.8156863 0.8352941 0.7372549
## [4,] 0.4156863 0.6352941 0.7803922 0.7921569 0.7921569 0.8039216 0.7607843
## [5,] 0.4470588 0.5960784 0.7176471 0.8509804 0.8352941 0.8196078 0.8509804
## [6,] 0.3882353 0.7647059 0.7450980 0.7098039 0.9176471 0.8078431 0.8000000
## [,323] [,324] [,325] [,326] [,327] [,328] [,329]
## [1,] 0.4274510 0.5137255 0.2745098 0.3960784 0.4470588 0.3294118 0.5490196
## [2,] 0.6705882 0.3686275 0.4078431 0.3176471 0.3647059 0.3294118 0.2588235
## [3,] 0.6470588 0.6078431 0.4392157 0.5333333 0.3254902 0.3294118 0.3647059
## [4,] 0.6823529 0.5647059 0.4470588 0.3411765 0.3647059 0.3176471 0.3372549
## [5,] 0.5725490 0.4313725 0.5098039 0.3882353 0.3294118 0.2823529 0.2509804
## [6,] 0.7294118 0.6352941 0.2862745 0.3764706 0.3803922 0.3921569 0.5529412
## [,330] [,331] [,332] [,333] [,334] [,335] [,336]
## [1,] 0.1882353 0.4039216 0.2117647 0.2705882 0.4862745 0.2941176 0.5176471
## [2,] 0.4549020 0.1529412 0.3137255 0.4117647 0.4078431 0.6862745 0.7882353
## [3,] 0.2313725 0.3686275 0.2666667 0.4745098 0.6078431 0.6901961 0.7098039
## [4,] 0.3921569 0.3137255 0.2588235 0.4901961 0.6392157 0.6862745 0.7725490
## [5,] 0.4156863 0.3411765 0.4313725 0.6392157 0.6509804 0.6352941 0.5921569
## [6,] 0.3294118 0.4078431 0.3254902 0.5058824 0.6941176 0.7176471 0.7921569
## [,337] [,338] [,339] [,340] [,341] [,342] [,343]
## [1,] 0.3372549 0.5019608 0.4549020 0.2784314 0.5137255 0.2235294 0.3137255
## [2,] 0.7647059 0.6431373 0.6274510 0.4784314 0.3137255 0.3490196 0.3490196
## [3,] 0.7647059 0.6745098 0.8196078 0.6392157 0.4078431 0.3254902 0.3843137
## [4,] 0.7725490 0.8470588 0.6784314 0.5333333 0.3019608 0.3294118 0.3568627
## [5,] 0.6627451 0.7450980 0.5882353 0.5098039 0.2745098 0.5098039 0.2509804
## [6,] 0.8235294 0.6392157 0.5098039 0.3411765 0.5647059 0.4235294 0.5294118
## [,344] [,345] [,346] [,347] [,348] [,349] [,350]
## [1,] 0.2235294 0.2784314 0.3882353 0.1490196 0.2862745 0.1333333 0.3098039
## [2,] 0.4117647 0.3803922 0.2862745 0.3921569 0.2470588 0.2862745 0.3686275
## [3,] 0.3294118 0.3647059 0.3686275 0.2470588 0.2627451 0.2666667 0.5137255
## [4,] 0.3137255 0.2901961 0.3411765 0.2509804 0.3411765 0.3686275 0.4980392
## [5,] 0.3529412 0.4156863 0.2274510 0.4823529 0.3098039 0.4313725 0.5607843
## [6,] 0.3058824 0.2078431 0.3843137 0.2039216 0.4588235 0.4117647 0.7137255
## [,351] [,352] [,353] [,354] [,355] [,356] [,357]
## [1,] 0.4117647 0.2941176 0.4745098 0.2901961 0.5215686 0.2196078 0.2980392
## [2,] 0.3254902 0.4941176 0.6156863 0.5960784 0.4745098 0.4274510 0.4039216
## [3,] 0.6549020 0.7686275 0.8156863 0.7647059 0.7960784 0.5960784 0.4196078
## [4,] 0.8941176 0.6980392 0.7921569 0.8588235 0.7098039 0.5490196 0.3647059
## [5,] 0.8431373 0.8431373 0.8470588 0.8666667 0.6588235 0.5568627 0.3647059
## [6,] 0.8078431 0.8392157 0.8509804 0.8392157 0.8078431 0.4941176 0.2901961
## [,358] [,359] [,360] [,361] [,362] [,363] [,364]
## [1,] 0.3686275 0.2627451 0.3137255 0.3254902 0.4392157 0.3019608 0.3254902
## [2,] 0.2823529 0.3411765 0.3960784 0.6039216 0.5294118 0.2862745 0.3137255
## [3,] 0.2980392 0.3803922 0.3725490 0.5176471 0.3607843 0.2000000 0.2313725
## [4,] 0.4588235 0.2823529 0.3686275 0.3803922 0.2980392 0.3137255 0.2784314
## [5,] 0.2235294 0.4666667 0.3490196 0.5176471 0.3843137 0.2862745 0.4117647
## [6,] 0.3882353 0.2196078 0.4078431 0.3372549 0.3058824 0.4313725 0.3411765
## [,365] [,366] [,367] [,368] [,369] [,370] [,371]
## [1,] 0.4000000 0.3450980 0.4352941 0.3137255 0.3333333 0.3254902 0.3764706
## [2,] 0.3098039 0.3725490 0.5254902 0.6196078 0.6000000 0.7254902 0.6196078
## [3,] 0.3647059 0.6470588 0.7725490 0.8352941 0.8980392 0.7529412 0.8156863
## [4,] 0.3607843 0.6627451 0.7333333 0.7843137 0.8274510 0.8666667 0.8235294
## [5,] 0.4039216 0.7960784 0.6941176 0.7725490 0.5960784 0.6862745 0.6666667
## [6,] 0.4823529 0.6078431 0.7294118 0.7607843 0.8392157 0.8156863 0.7294118
## [,372] [,373] [,374] [,375] [,376] [,377] [,378]
## [1,] 0.3450980 0.3686275 0.3725490 0.3568627 0.2156863 0.3058824 0.4274510
## [2,] 0.5098039 0.4705882 0.2980392 0.2980392 0.3921569 0.2784314 0.4352941
## [3,] 0.7960784 0.5450980 0.3450980 0.2509804 0.3725490 0.2823529 0.4196078
## [4,] 0.7176471 0.3764706 0.3176471 0.3686275 0.2235294 0.4000000 0.4352941
## [5,] 0.5254902 0.5372549 0.5176471 0.2470588 0.3843137 0.2784314 0.5607843
## [6,] 0.5294118 0.3137255 0.3843137 0.4392157 0.2941176 0.5137255 0.4196078
## [,379] [,380] [,381] [,382] [,383] [,384] [,385]
## [1,] 0.5137255 0.5686275 0.4823529 0.5529412 0.7019608 0.4941176 0.5764706
## [2,] 0.4156863 0.3568627 0.5215686 0.7294118 0.7764706 0.7411765 0.8078431
## [3,] 0.3960784 0.3450980 0.3803922 0.6549020 0.9411765 0.8549020 0.7843137
## [4,] 0.5686275 0.3725490 0.2862745 0.6078431 0.8117647 0.8666667 0.8509804
## [5,] 0.4196078 0.3058824 0.4784314 0.5372549 0.5843137 0.6980392 0.7254902
## [6,] 0.4274510 0.3686275 0.4235294 0.6745098 0.7960784 0.8156863 0.6431373
## [,386] [,387] [,388] [,389] [,390] [,391] [,392]
## [1,] 0.4784314 0.4901961 0.7058824 0.7411765 0.5058824 0.3215686 0.3019608
## [2,] 0.6862745 0.8000000 0.7215686 0.4823529 0.4470588 0.4941176 0.3333333
## [3,] 0.7882353 0.7607843 0.7137255 0.4156863 0.4627451 0.3529412 0.3411765
## [4,] 0.8980392 0.7843137 0.6470588 0.5960784 0.4352941 0.3098039 0.3921569
## [5,] 0.8549020 0.6941176 0.6470588 0.3411765 0.3921569 0.3607843 0.3764706
## [6,] 0.7529412 0.8549020 0.7450980 0.5254902 0.4666667 0.5098039 0.3568627
## [,393] [,394] [,395] [,396] [,397] [,398] [,399]
## [1,] 0.3215686 0.4862745 0.5686275 0.3882353 0.3215686 0.2980392 0.3607843
## [2,] 0.4235294 0.4156863 0.3098039 0.3529412 0.3411765 0.4431373 0.5882353
## [3,] 0.3960784 0.2627451 0.3882353 0.2509804 0.3137255 0.6000000 0.7176471
## [4,] 0.2666667 0.2941176 0.3215686 0.3058824 0.2352941 0.6627451 0.7490196
## [5,] 0.5411765 0.2980392 0.3176471 0.1843137 0.3921569 0.7137255 0.7411765
## [6,] 0.3411765 0.4274510 0.1882353 0.2705882 0.2941176 0.4823529 0.7529412
## [,400] [,401] [,402] [,403] [,404] [,405] [,406]
## [1,] 0.3294118 0.3333333 0.5529412 0.4470588 0.2823529 0.3254902 0.3254902
## [2,] 0.5176471 0.6823529 0.7098039 0.6549020 0.4627451 0.2588235 0.4980392
## [3,] 0.6784314 0.8196078 0.8274510 0.7568627 0.5372549 0.4784314 0.3607843
## [4,] 0.8000000 0.7921569 0.7725490 0.7137255 0.5098039 0.3568627 0.5411765
## [5,] 0.8509804 0.8431373 0.7019608 0.8509804 0.7960784 0.5529412 0.4980392
## [6,] 0.8470588 0.8980392 0.8352941 0.7372549 0.6117647 0.5098039 0.4509804
## [,407] [,408] [,409] [,410] [,411] [,412] [,413]
## [1,] 0.4509804 0.3960784 0.3215686 0.2431373 0.3019608 0.3372549 0.3098039
## [2,] 0.3686275 0.3607843 0.2039216 0.3490196 0.4156863 0.3333333 0.6274510
## [3,] 0.5607843 0.2470588 0.3725490 0.3647059 0.2941176 0.4470588 0.3921569
## [4,] 0.3254902 0.4235294 0.3098039 0.4235294 0.4941176 0.4196078 0.6588235
## [5,] 0.5647059 0.3372549 0.4392157 0.4588235 0.4862745 0.4509804 0.3764706
## [6,] 0.4352941 0.4196078 0.4627451 0.4627451 0.3725490 0.3019608 0.3607843
## [,414] [,415] [,416] [,417] [,418] [,419] [,420]
## [1,] 0.4588235 0.4117647 0.3176471 0.3333333 0.3176471 0.4156863 0.3450980
## [2,] 0.4823529 0.5607843 0.4627451 0.4000000 0.5254902 0.5333333 0.5529412
## [3,] 0.7176471 0.8705882 0.7803922 0.6980392 0.6196078 0.7490196 0.5960784
## [4,] 0.8627451 0.7019608 0.7803922 0.7764706 0.8509804 0.7843137 0.7529412
## [5,] 0.8156863 0.7019608 0.8627451 0.7490196 0.9137255 0.8117647 0.6156863
## [6,] 0.6549020 0.7921569 0.8431373 0.9254902 0.8000000 0.7450980 0.5843137
## [,421] [,422] [,423] [,424] [,425] [,426] [,427]
## [1,] 0.3568627 0.6274510 0.2745098 0.3882353 0.2235294 0.3568627 0.3529412
## [2,] 0.4039216 0.4313725 0.3215686 0.2784314 0.3725490 0.2392157 0.3254902
## [3,] 0.4627451 0.5725490 0.3647059 0.4156863 0.1686275 0.3725490 0.2705882
## [4,] 0.4627451 0.2941176 0.4274510 0.2549020 0.3921569 0.3098039 0.2431373
## [5,] 0.5882353 0.4666667 0.4078431 0.5176471 0.3764706 0.3843137 0.2980392
## [6,] 0.4039216 0.4392157 0.4980392 0.3843137 0.3490196 0.3647059 0.3176471
## [,428] [,429] [,430] [,431] [,432] [,433] [,434]
## [1,] 0.2823529 0.5176471 0.3372549 0.5294118 0.3490196 0.4745098 0.6196078
## [2,] 0.3960784 0.3725490 0.5490196 0.7921569 0.7764706 0.7647059 0.7647059
## [3,] 0.3529412 0.7372549 0.7686275 0.8196078 0.7607843 0.8039216 0.7607843
## [4,] 0.4352941 0.5254902 0.7529412 0.7450980 0.9215686 0.8627451 0.8392157
## [5,] 0.4196078 0.5333333 0.7098039 0.5725490 0.7568627 0.8156863 0.7686275
## [6,] 0.3098039 0.5137255 0.6862745 0.8313725 0.6313725 0.7529412 0.7450980
## [,435] [,436] [,437] [,438] [,439] [,440] [,441]
## [1,] 0.6039216 0.5764706 0.2666667 0.3725490 0.3215686 0.4039216 0.6352941
## [2,] 0.6666667 0.4274510 0.4745098 0.3137255 0.2705882 0.3960784 0.2117647
## [3,] 0.7882353 0.5803922 0.3137255 0.3490196 0.3921569 0.2470588 0.3843137
## [4,] 0.7215686 0.4588235 0.4784314 0.3882353 0.3372549 0.3647059 0.3176471
## [5,] 0.8000000 0.5568627 0.3882353 0.3215686 0.4039216 0.3686275 0.3843137
## [6,] 0.7098039 0.5098039 0.3960784 0.4823529 0.4431373 0.2627451 0.3921569
## [,442] [,443] [,444] [,445] [,446] [,447] [,448]
## [1,] 0.2901961 0.4627451 0.2117647 0.2156863 0.4862745 0.4627451 0.5137255
## [2,] 0.4588235 0.2588235 0.3372549 0.4000000 0.3725490 0.5529412 0.6509804
## [3,] 0.1803922 0.3607843 0.2392157 0.3019608 0.5372549 0.7882353 0.7490196
## [4,] 0.4039216 0.3215686 0.2784314 0.4000000 0.5254902 0.6941176 0.8549020
## [5,] 0.4274510 0.4784314 0.4549020 0.5372549 0.6039216 0.6705882 0.9176471
## [6,] 0.1294118 0.4901961 0.3098039 0.3921569 0.6980392 0.7372549 0.7215686
## [,449] [,450] [,451] [,452] [,453] [,454] [,455]
## [1,] 0.4235294 0.5960784 0.6117647 0.3843137 0.4705882 0.2392157 0.3686275
## [2,] 0.5960784 0.5647059 0.6666667 0.7803922 0.4745098 0.4941176 0.2980392
## [3,] 0.7960784 0.7607843 0.6156863 0.6862745 0.6235294 0.3529412 0.6431373
## [4,] 0.7960784 0.8078431 0.8039216 0.5921569 0.3725490 0.3137255 0.2784314
## [5,] 0.8862745 0.7568627 0.8000000 0.5529412 0.4274510 0.3647059 0.2980392
## [6,] 0.7921569 0.8078431 0.8862745 0.6941176 0.5254902 0.1490196 0.3764706
## [,456] [,457] [,458] [,459] [,460] [,461] [,462]
## [1,] 0.2588235 0.2941176 0.3803922 0.2274510 0.2941176 0.2823529 0.3725490
## [2,] 0.4431373 0.4745098 0.2862745 0.3019608 0.2980392 0.4000000 0.4705882
## [3,] 0.4745098 0.3294118 0.3254902 0.1803922 0.2901961 0.5411765 0.6980392
## [4,] 0.3568627 0.2352941 0.2941176 0.3490196 0.3960784 0.6392157 0.7411765
## [5,] 0.4039216 0.3960784 0.4156863 0.5098039 0.4196078 0.5803922 0.8117647
## [6,] 0.2431373 0.3137255 0.5019608 0.1686275 0.3411765 0.5058824 0.6392157
## [,463] [,464] [,465] [,466] [,467] [,468] [,469]
## [1,] 0.4078431 0.2980392 0.4823529 0.3019608 0.4509804 0.3607843 0.3294118
## [2,] 0.6705882 0.6470588 0.7960784 0.6745098 0.6666667 0.6509804 0.3764706
## [3,] 0.8274510 1.0000000 0.8705882 0.8980392 0.8392157 0.6509804 0.3450980
## [4,] 0.8431373 0.8313725 0.8352941 0.7960784 0.8509804 0.5764706 0.4431373
## [5,] 0.7333333 0.7960784 0.7411765 0.7294118 0.8235294 0.7294118 0.7098039
## [6,] 0.7294118 0.8431373 0.7882353 0.6549020 0.8000000 0.4862745 0.4431373
## [,470] [,471] [,472] [,473] [,474] [,475] [,476]
## [1,] 0.5254902 0.1764706 0.3019608 0.1725490 0.2509804 0.3372549 0.2196078
## [2,] 0.3019608 0.4392157 0.2392157 0.3921569 0.2313725 0.2745098 0.4000000
## [3,] 0.4823529 0.3686275 0.4470588 0.2666667 0.3176471 0.2941176 0.3529412
## [4,] 0.4156863 0.3254902 0.3803922 0.3019608 0.2901961 0.3333333 0.3215686
## [5,] 0.4000000 0.2980392 0.2862745 0.4313725 0.4235294 0.3176471 0.4078431
## [6,] 0.5215686 0.2470588 0.4745098 0.3019608 0.3254902 0.3764706 0.2941176
## [,477] [,478] [,479] [,480] [,481] [,482] [,483]
## [1,] 0.5215686 0.3803922 0.5019608 0.5803922 0.5529412 0.5882353 0.5058824
## [2,] 0.4117647 0.6509804 0.7647059 0.7843137 0.7372549 0.8392157 0.7490196
## [3,] 0.5137255 0.6352941 0.8705882 0.9176471 0.8823529 0.9568627 0.8431373
## [4,] 0.4078431 0.6745098 0.6901961 0.7098039 0.7921569 0.7725490 0.7294118
## [5,] 0.4117647 0.5019608 0.7411765 0.8705882 0.8431373 0.7333333 0.7568627
## [6,] 0.5058824 0.7764706 0.7725490 0.6705882 0.7294118 0.6705882 0.6862745
## [,484] [,485] [,486] [,487] [,488] [,489] [,490]
## [1,] 0.5686275 0.4078431 0.2862745 0.3098039 0.2588235 0.4666667 0.3960784
## [2,] 0.6431373 0.4627451 0.4117647 0.3215686 0.3372549 0.2392157 0.4784314
## [3,] 0.7058824 0.4549020 0.3725490 0.3254902 0.3058824 0.5019608 0.4470588
## [4,] 0.6705882 0.5411765 0.4117647 0.4196078 0.4392157 0.4470588 0.4078431
## [5,] 0.5686275 0.6627451 0.5764706 0.4627451 0.6666667 0.2823529 0.4117647
## [6,] 0.7254902 0.5843137 0.3568627 0.5215686 0.2274510 0.4313725 0.3098039
## [,491] [,492] [,493] [,494] [,495] [,496] [,497]
## [1,] 0.4823529 0.5568627 0.3686275 0.4313725 0.4274510 0.5137255 0.5647059
## [2,] 0.3254902 0.2705882 0.3490196 0.6000000 0.7333333 0.8117647 0.6627451
## [3,] 0.3843137 0.3333333 0.4470588 0.7176471 0.6980392 0.8941176 0.7450980
## [4,] 0.3333333 0.4039216 0.5294118 0.7882353 0.8274510 0.7254902 0.8235294
## [5,] 0.3137255 0.3254902 0.6000000 0.8431373 0.8039216 0.7450980 0.7098039
## [6,] 0.4274510 0.4666667 0.5568627 0.7647059 0.7490196 0.7882353 0.8627451
## [,498] [,499] [,500] [,501] [,502] [,503] [,504]
## [1,] 0.4274510 0.3686275 0.2470588 0.2980392 0.3176471 0.2509804 0.3215686
## [2,] 0.5725490 0.4705882 0.4274510 0.3098039 0.2980392 0.2588235 0.2901961
## [3,] 0.7568627 0.4470588 0.4705882 0.3333333 0.4627451 0.3176471 0.3058824
## [4,] 0.7647059 0.6627451 0.4705882 0.4784314 0.3176471 0.3254902 0.3529412
## [5,] 0.7725490 0.8039216 0.4980392 0.2941176 0.4235294 0.3843137 0.1882353
## [6,] 0.8431373 0.7647059 0.4627451 0.5764706 0.4549020 0.3098039 0.4039216
## [,505] [,506] [,507] [,508] [,509] [,510] [,511]
## [1,] 0.2627451 0.3176471 0.2352941 0.3019608 0.3803922 0.2941176 0.2941176
## [2,] 0.4117647 0.2470588 0.2862745 0.3411765 0.3019608 0.3607843 0.4509804
## [3,] 0.3803922 0.2745098 0.3450980 0.2941176 0.4274510 0.6196078 0.5764706
## [4,] 0.2823529 0.3921569 0.3215686 0.3254902 0.5058824 0.6274510 0.6784314
## [5,] 0.3686275 0.1686275 0.4588235 0.4078431 0.3137255 0.6156863 0.6862745
## [6,] 0.2352941 0.4549020 0.2039216 0.3568627 0.4431373 0.3568627 0.7411765
## [,512]
## [1,] 0.3568627
## [2,] 0.4784314
## [3,] 0.7411765
## [4,] 0.7098039
## [5,] 0.7137255
## [6,] 0.8196078
length(pixel_values)
## [1] 262144
# Plot the histogram
hist(pixel_values, main = "Pixel Value Histogram", xlab = "Pixel Value", ylab = "Frequency", col = "lightblue", border = "black")
After plotting the data, we tried to fit the data to Normal distribution but it failed. Then we proceed with the Bimodal Distribution.
# Check normality, it fails
sample <- sample(pixel_values,1000,replace = FALSE)
shapiro.test(sample)
##
## Shapiro-Wilk normality test
##
## data: sample
## W = 0.91464, p-value < 2.2e-16
# Fit the pixel values to a bimodal distribution
fit_result <- normalmixEM(pixel_values, k = 2) # 'k' specifies the number of components in the mixture model
## number of iterations= 100
# Part1.2
# Extract mean and variance for each mode
mean_mode1 <- fit_result$mu[1]
variance_mode1 <- fit_result$sigma[1]^2
mean_mode2 <- fit_result$mu[2]
variance_mode2 <- fit_result$sigma[2]^2
# Check the bimodal distribution
x_values <- seq(min(pixel_values), max(pixel_values), length.out = 1000)
# Calculate PDF values for each mode
pdf_mode1 <- dnorm(x_values, mean = mean_mode1, sd = sqrt(variance_mode1))
pdf_mode2 <- dnorm(x_values, mean = mean_mode2, sd = sqrt(variance_mode2))
# Combine the PDFs for the bimodal distribution
pdf_bimodal <- 0.5 * pdf_mode1 + 0.5 * pdf_mode2
# Plot the bimodal distribution
plot(x_values, pdf_bimodal, type = "l", col = "blue", lwd = 2, ylab = "Probability Density", xlab = "Pixel Values", main = "Bimodal Distribution Fit")
lines(x_values, 0.5 * pdf_mode1, col = "red", lty = 2, lwd = 2) # Plot mode 1
lines(x_values, 0.5 * pdf_mode2, col = "green", lty = 2, lwd = 2) # Plot mode 2
legend("topright", legend = c("Bimodal Distribution", "Mode 1", "Mode 2"), col = c("blue", "red", "green"), lty = c(1, 2, 2), lwd = 2)
After finding the distribution, limits to detect the outliers are determined. After that, the values lying outside the limits are selected and painted to black (decreased their value to 0).
#Part 1.3: Outlier detection
# Calculate lower and upper bounds for 0.001 probability limits
lower_bound <- qnorm(0.001, mean_mode1, sqrt(variance_mode1))
upper_bound <- qnorm(0.999, mean_mode2, sqrt(variance_mode2))
# Identify pixels outside the bounds
# Identify pixels outside the bounds and get their indices
outlier_indices <- which(pixel_values < lower_bound | pixel_values > upper_bound)
outlier_indices
## [1] 121050 129547 129571 129845 131879 132801 133710 137582 139854 146831
## [11] 154148 158721 159527 159745 160592 163101 165676 166765 167674 168439
## [21] 173147 174195 174363 175824 177143 178509 179286 179420 182899 184922
## [31] 185877 186903 189451 191090 192810 194940 196159 196826 197222 197735
## [41] 200283 203759 205357 205643 206542 207475 207773 208066 208286 209078
## [51] 210165 211467 211892 213917 214606 214999 215620 215947 218183 220129
## [61] 223535 224427 224576 227043 228463 230771 232381 233146 234087 236524
## [71] 245053 251238 251507 252428 253750 255091 256461 257656
img_outliers_removed<- img
img_outliers_removed[outlier_indices] <- 0
# Display the original and new images in a plot
par(mfrow=c(1,2))
# Original Image
plot(1, type='n', xlab='', ylab='', xlim=c(0, 512), ylim=c(0, 512))
rasterImage(img, 0, 0, 512, 512)
# Add titles to the plots
title(main="Original Image", xlab = "Pixel Value", ylab = "Frequency", line = 0.2)
# New Image with Outliers Removed
plot(1, type='n', xlab='', ylab='', xlim=c(0, 512), ylim=c(0, 512))
rasterImage(img_outliers_removed, 0, 0, 512, 512)
title(main="Without Outliers", xlab = "Pixel Value", ylab = "Frequency", line = 0.2)
Although this method finds some outliers, resulting image shows us that the current method is not sufficient to detect the parts we need.
# Part 1.4: Image Operations on Patches
# Define window size
window_size <- 51
# Update the operate_on_patches function
operate_on_patches <- function(image, window_size) {
# Get the dimensions of the image
dimensions <- dim(image)
print(dimensions)
# Extract the number of rows (assuming the image is a matrix)
x <- dimensions[1]
# Calculate the number of patches in each dimension
n_of_patch <- x %/% window_size
print(n_of_patch)
# Iterate over each patch
for (i in 1:n_of_patch) {
for (j in 1:n_of_patch) {
# Calculate the indices for the current patch
row_indices <- (window_size * (i - 1) + 1):(window_size * i)
col_indices <- (window_size * (j - 1) + 1):(window_size * j)
# Ensure indices do not go out of bounds
row_indices <- row_indices[row_indices <= x]
col_indices <- col_indices[col_indices <= x]
# Extract the current patch from the image
patch <- image[row_indices, col_indices]
# Fit a bimodal normal distribution to the current patch
patch_fit_result <- normalmixEM(patch, k = 2)
# Extract mean and variance for each mode
patch_mean_mode1 <- patch_fit_result$mu[1]
patch_variance_mode1 <- patch_fit_result$sigma[1]^2
patch_mean_mode2 <- patch_fit_result$mu[2]
patch_variance_mode2 <- patch_fit_result$sigma[2]^2
# Calculate lower and upper bounds for 0.001 probability limits
patch_lower_bound <- qnorm(0.001, patch_mean_mode1, sqrt(patch_variance_mode1))
patch_upper_bound <- qnorm(0.999, patch_mean_mode2, sqrt(patch_variance_mode2))
# Threshold the pixel values in the patch based on probability limits
patch[patch < patch_lower_bound | patch > patch_upper_bound] <- 0
# Update the original image with the modified patch
image[row_indices, col_indices] <- patch
}
}
# Return the modified image
return(image)
}
patch_img = operate_on_patches(img,window_size)
## [1] 512 512
## [1] 10
## number of iterations= 120
## number of iterations= 186
## number of iterations= 119
## number of iterations= 100
## number of iterations= 72
## number of iterations= 62
## number of iterations= 110
## number of iterations= 91
## number of iterations= 81
## number of iterations= 71
## number of iterations= 96
## number of iterations= 112
## number of iterations= 80
## number of iterations= 97
## number of iterations= 94
## number of iterations= 94
## number of iterations= 77
## number of iterations= 95
## number of iterations= 81
## number of iterations= 84
## number of iterations= 182
## number of iterations= 112
## number of iterations= 126
## number of iterations= 113
## number of iterations= 66
## number of iterations= 106
## number of iterations= 67
## number of iterations= 46
## number of iterations= 92
## number of iterations= 74
## number of iterations= 85
## number of iterations= 125
## number of iterations= 112
## number of iterations= 79
## number of iterations= 91
## number of iterations= 91
## number of iterations= 89
## number of iterations= 65
## number of iterations= 96
## number of iterations= 64
## number of iterations= 115
## number of iterations= 92
## number of iterations= 101
## number of iterations= 88
## number of iterations= 79
## number of iterations= 121
## number of iterations= 76
## number of iterations= 66
## number of iterations= 100
## number of iterations= 67
## number of iterations= 99
## number of iterations= 96
## number of iterations= 113
## number of iterations= 97
## number of iterations= 85
## number of iterations= 96
## number of iterations= 93
## number of iterations= 87
## number of iterations= 48
## number of iterations= 73
## number of iterations= 92
## number of iterations= 82
## number of iterations= 85
## number of iterations= 103
## number of iterations= 68
## number of iterations= 94
## number of iterations= 78
## number of iterations= 124
## number of iterations= 96
## number of iterations= 73
## number of iterations= 115
## number of iterations= 179
## number of iterations= 99
## number of iterations= 91
## number of iterations= 44
## number of iterations= 73
## number of iterations= 84
## number of iterations= 84
## number of iterations= 95
## number of iterations= 85
## number of iterations= 98
## number of iterations= 100
## number of iterations= 106
## number of iterations= 88
## number of iterations= 97
## number of iterations= 86
## number of iterations= 62
## number of iterations= 82
## number of iterations= 76
## number of iterations= 73
## number of iterations= 77
## number of iterations= 80
## number of iterations= 106
## number of iterations= 77
## number of iterations= 62
## number of iterations= 92
## number of iterations= 77
## number of iterations= 102
## number of iterations= 64
## number of iterations= 63
# Display the original and new images in a plot
par(mfrow = c(1, 2))
# Original Image
plot(1, type = 'n', xlab = '', ylab = '', xlim = c(0, 512), ylim = c(0, 512))
rasterImage(img, 0, 0, 512, 512)
title(main = "Original Image", xlab = "Pixel Value", ylab = "Frequency", line = 0.2)
# New Image with Outliers Removed in Patches
plot(1, type = 'n', xlab = '', ylab = '', xlim = c(0, 512), ylim = c(0, 512))
rasterImage(patch_img, 0, 0, 512, 512)
title(main = "Without Outliers in Patches", xlab = "Pixel Value", ylab = "Frequency", line = 0.2)
# Reset the plot layout
par(mfrow = c(1, 1))
In part 1.4, we divided our data into small samples. Patches of 51x51 pixels are used to determine mean, variance, upper and lower limits. Results shows us that the function found 4 problematic patches. In only one of them, there was a problem. It might be considered as a success but the accuracy is not good.
A Simple Defect Detection Approach from a Control Chart Perspective:
In this part, there is a assumption that every row’s and column’s distribution is same. Therefore, the first column and the row of the image is selected and the upper and lower limits are determined by fitting the distributions.
# Part 2.1
# Read the color image
img <- readJPEG("~/Desktop/Dersler/IE423/outputimage.jpg")
# Define second image
part2_img = img
# Assuming all the rows have the same distribution of pixels
row1 = img[1,]
head(row1)
## [1] 0.7490196 0.7490196 0.6980392 0.6117647 0.5294118 0.4274510
# Display the distribution of row
hist(row1, main = "Pixel Value Histogram", xlab = "Pixel Value", ylab = "Frequency", col = "lightblue", border = "black")
# Check normality, it fails
row1_array = as.array(row1)
sample <- sample(row1,100,replace = FALSE)
shapiro.test(sample)
##
## Shapiro-Wilk normality test
##
## data: sample
## W = 0.96166, p-value = 0.005293
# Fit the pixel values to a bimodal distribution
fit_result <- normalmixEM(row1, k = 2) # 'k' specifies the number of components in the mixture model
## number of iterations= 190
fit_result
## $x
## [1] 0.7490196 0.7490196 0.6980392 0.6117647 0.5294118 0.4274510 0.3490196
## [8] 0.3294118 0.3450980 0.3490196 0.3647059 0.3921569 0.4352941 0.5098039
## [15] 0.6078431 0.6862745 0.7411765 0.7058824 0.6509804 0.6392157 0.5411765
## [22] 0.5058824 0.4274510 0.3764706 0.3764706 0.3450980 0.3215686 0.3372549
## [29] 0.3882353 0.4666667 0.5529412 0.6156863 0.6705882 0.6196078 0.5529412
## [36] 0.4980392 0.4509804 0.4156863 0.4078431 0.4156863 0.4235294 0.4039216
## [43] 0.4196078 0.4509804 0.4901961 0.5764706 0.6666667 0.7019608 0.7333333
## [50] 0.7372549 0.6588235 0.5882353 0.5372549 0.4980392 0.4745098 0.4078431
## [57] 0.4000000 0.3607843 0.3215686 0.3764706 0.5098039 0.6196078 0.6745098
## [64] 0.7215686 0.7215686 0.7529412 0.7450980 0.6509804 0.4862745 0.4235294
## [71] 0.3098039 0.2941176 0.2823529 0.3372549 0.4000000 0.4470588 0.5058824
## [78] 0.6078431 0.7294118 0.8078431 0.7960784 0.7647059 0.6980392 0.5450980
## [85] 0.4666667 0.3529412 0.3372549 0.3411765 0.3960784 0.3843137 0.3764706
## [92] 0.3882353 0.4274510 0.4784314 0.5254902 0.5529412 0.5411765 0.5882353
## [99] 0.5372549 0.4745098 0.4078431 0.3411765 0.3333333 0.3215686 0.3607843
## [106] 0.3921569 0.3568627 0.3215686 0.2862745 0.3098039 0.4235294 0.4823529
## [113] 0.5294118 0.6039216 0.6039216 0.5215686 0.5098039 0.4627451 0.3686275
## [120] 0.3882353 0.3686275 0.3686275 0.3725490 0.3843137 0.3921569 0.4039216
## [127] 0.4196078 0.4313725 0.4431373 0.4862745 0.4666667 0.4470588 0.3921569
## [134] 0.3490196 0.3607843 0.3490196 0.3764706 0.3803922 0.4235294 0.4588235
## [141] 0.4549020 0.4941176 0.6078431 0.7058824 0.7607843 0.7137255 0.6745098
## [148] 0.5843137 0.3529412 0.3294118 0.3490196 0.3098039 0.3098039 0.3568627
## [155] 0.3450980 0.3058824 0.2784314 0.3647059 0.5294118 0.5764706 0.6392157
## [162] 0.6470588 0.6549020 0.6392157 0.5725490 0.4705882 0.4000000 0.3803922
## [169] 0.3607843 0.2862745 0.2745098 0.2784314 0.3411765 0.4470588 0.4823529
## [176] 0.4862745 0.5098039 0.5490196 0.5372549 0.5529412 0.4901961 0.3372549
## [183] 0.3058824 0.3647059 0.4745098 0.4627451 0.4470588 0.4549020 0.4352941
## [190] 0.4862745 0.6039216 0.6196078 0.6039216 0.6588235 0.6117647 0.3843137
## [197] 0.3450980 0.3803922 0.3098039 0.3960784 0.3764706 0.3803922 0.3843137
## [204] 0.4274510 0.4941176 0.5098039 0.5098039 0.5294118 0.6117647 0.4431373
## [211] 0.3960784 0.4627451 0.4588235 0.4196078 0.3764706 0.3137255 0.3019608
## [218] 0.2784314 0.2823529 0.2980392 0.2941176 0.3882353 0.3333333 0.3490196
## [225] 0.3372549 0.3294118 0.2980392 0.4588235 0.4313725 0.3725490 0.3529412
## [232] 0.3764706 0.4196078 0.3843137 0.4274510 0.2627451 0.3058824 0.3568627
## [239] 0.3254902 0.4078431 0.3215686 0.3960784 0.3607843 0.2980392 0.4588235
## [246] 0.4117647 0.5372549 0.4470588 0.4784314 0.4470588 0.3372549 0.4117647
## [253] 0.4862745 0.7058824 0.5215686 0.4392157 0.4000000 0.3686275 0.3843137
## [260] 0.3215686 0.3607843 0.2980392 0.2823529 0.3568627 0.2666667 0.3490196
## [267] 0.2784314 0.3411765 0.4156863 0.3529412 0.3647059 0.3607843 0.4549020
## [274] 0.4862745 0.2666667 0.4156863 0.2823529 0.3333333 0.2705882 0.2980392
## [281] 0.4862745 0.3450980 0.4156863 0.2588235 0.3215686 0.3960784 0.2392157
## [288] 0.5803922 0.3058824 0.3803922 0.2862745 0.2941176 0.3803922 0.2470588
## [295] 0.3490196 0.2509804 0.2117647 0.2588235 0.2627451 0.4392157 0.2235294
## [302] 0.3960784 0.2901961 0.2627451 0.3725490 0.2784314 0.4784314 0.3764706
## [309] 0.5254902 0.4156863 0.1215686 0.3725490 0.1254902 0.3921569 0.3176471
## [316] 0.2705882 0.3725490 0.2235294 0.4431373 0.4627451 0.5019608 0.6784314
## [323] 0.4274510 0.5137255 0.2745098 0.3960784 0.4470588 0.3294118 0.5490196
## [330] 0.1882353 0.4039216 0.2117647 0.2705882 0.4862745 0.2941176 0.5176471
## [337] 0.3372549 0.5019608 0.4549020 0.2784314 0.5137255 0.2235294 0.3137255
## [344] 0.2235294 0.2784314 0.3882353 0.1490196 0.2862745 0.1333333 0.3098039
## [351] 0.4117647 0.2941176 0.4745098 0.2901961 0.5215686 0.2196078 0.2980392
## [358] 0.3686275 0.2627451 0.3137255 0.3254902 0.4392157 0.3019608 0.3254902
## [365] 0.4000000 0.3450980 0.4352941 0.3137255 0.3333333 0.3254902 0.3764706
## [372] 0.3450980 0.3686275 0.3725490 0.3568627 0.2156863 0.3058824 0.4274510
## [379] 0.5137255 0.5686275 0.4823529 0.5529412 0.7019608 0.4941176 0.5764706
## [386] 0.4784314 0.4901961 0.7058824 0.7411765 0.5058824 0.3215686 0.3019608
## [393] 0.3215686 0.4862745 0.5686275 0.3882353 0.3215686 0.2980392 0.3607843
## [400] 0.3294118 0.3333333 0.5529412 0.4470588 0.2823529 0.3254902 0.3254902
## [407] 0.4509804 0.3960784 0.3215686 0.2431373 0.3019608 0.3372549 0.3098039
## [414] 0.4588235 0.4117647 0.3176471 0.3333333 0.3176471 0.4156863 0.3450980
## [421] 0.3568627 0.6274510 0.2745098 0.3882353 0.2235294 0.3568627 0.3529412
## [428] 0.2823529 0.5176471 0.3372549 0.5294118 0.3490196 0.4745098 0.6196078
## [435] 0.6039216 0.5764706 0.2666667 0.3725490 0.3215686 0.4039216 0.6352941
## [442] 0.2901961 0.4627451 0.2117647 0.2156863 0.4862745 0.4627451 0.5137255
## [449] 0.4235294 0.5960784 0.6117647 0.3843137 0.4705882 0.2392157 0.3686275
## [456] 0.2588235 0.2941176 0.3803922 0.2274510 0.2941176 0.2823529 0.3725490
## [463] 0.4078431 0.2980392 0.4823529 0.3019608 0.4509804 0.3607843 0.3294118
## [470] 0.5254902 0.1764706 0.3019608 0.1725490 0.2509804 0.3372549 0.2196078
## [477] 0.5215686 0.3803922 0.5019608 0.5803922 0.5529412 0.5882353 0.5058824
## [484] 0.5686275 0.4078431 0.2862745 0.3098039 0.2588235 0.4666667 0.3960784
## [491] 0.4823529 0.5568627 0.3686275 0.4313725 0.4274510 0.5137255 0.5647059
## [498] 0.4274510 0.3686275 0.2470588 0.2980392 0.3176471 0.2509804 0.3215686
## [505] 0.2627451 0.3176471 0.2352941 0.3019608 0.3803922 0.2941176 0.2941176
## [512] 0.3568627
##
## $lambda
## [1] 0.4355205 0.5644795
##
## $mu
## [1] 0.3411211 0.4779654
##
## $sigma
## [1] 0.06076485 0.13619389
##
## $loglik
## [1] 352.8452
##
## $posterior
## comp.1 comp.2
## [1,] 2.056506e-09 1.0000000
## [2,] 2.056506e-09 1.0000000
## [3,] 2.056113e-07 0.9999998
## [4,] 1.379393e-04 0.9998621
## [5,] 1.504055e-02 0.9849595
## [6,] 4.030592e-01 0.5969408
## [7,] 7.285850e-01 0.2714150
## [8,] 7.547315e-01 0.2452685
## [9,] 7.352526e-01 0.2647474
## [10,] 7.285850e-01 0.2714150
## [11,] 6.938469e-01 0.3061531
## [12,] 5.971197e-01 0.4028803
## [13,] 3.533964e-01 0.6466036
## [14,] 3.633229e-02 0.9636677
## [15,] 1.784416e-04 0.9998216
## [16,] 5.492826e-07 0.9999995
## [17,] 4.332574e-09 1.0000000
## [18,] 1.050277e-07 0.9999999
## [19,] 8.745930e-06 0.9999913
## [20,] 2.072021e-05 0.9999793
## [21,] 8.457835e-03 0.9915422
## [22,] 4.280775e-02 0.9571922
## [23,] 4.030592e-01 0.5969408
## [24,] 6.584001e-01 0.3415999
## [25,] 6.584001e-01 0.3415999
## [26,] 7.352526e-01 0.2647474
## [27,] 7.604738e-01 0.2395262
## [28,] 7.463795e-01 0.2536205
## [29,] 6.139995e-01 0.3860005
## [30,] 1.703407e-01 0.8296593
## [31,] 4.602654e-03 0.9953973
## [32,] 1.062741e-04 0.9998937
## [33,] 1.943172e-06 0.9999981
## [34,] 8.160466e-05 0.9999184
## [35,] 4.602654e-03 0.9953973
## [36,] 5.864689e-02 0.9413531
## [37,] 2.559756e-01 0.7440244
## [38,] 4.748611e-01 0.5251389
## [39,] 5.193427e-01 0.4806573
## [40,] 4.748611e-01 0.5251389
## [41,] 4.275060e-01 0.5724940
## [42,] 5.402702e-01 0.4597298
## [43,] 4.514858e-01 0.5485142
## [44,] 2.559756e-01 0.7440244
## [45,] 7.888266e-02 0.9211173
## [46,] 1.240178e-03 0.9987598
## [47,] 2.642822e-06 0.9999974
## [48,] 1.471973e-07 0.9999999
## [49,] 9.006725e-09 1.0000000
## [50,] 6.257211e-09 1.0000000
## [51,] 4.839883e-06 0.9999952
## [52,] 6.147564e-04 0.9993852
## [53,] 1.028504e-02 0.9897150
## [54,] 5.864689e-02 0.9413531
## [55,] 1.345468e-01 0.8654532
## [56,] 5.193427e-01 0.4806573
## [57,] 5.602349e-01 0.4397651
## [58,] 7.038069e-01 0.2961931
## [59,] 7.604738e-01 0.2395262
## [60,] 6.584001e-01 0.3415999
## [61,] 3.633229e-02 0.9636677
## [62,] 8.160466e-05 0.9999184
## [63,] 1.423986e-06 0.9999986
## [64,] 2.632889e-08 1.0000000
## [65,] 2.632889e-08 1.0000000
## [66,] 1.409772e-09 1.0000000
## [67,] 2.989940e-09 1.0000000
## [68,] 8.745930e-06 0.9999913
## [69,] 9.082929e-02 0.9091707
## [70,] 4.275060e-01 0.5724940
## [71,] 7.644376e-01 0.2355624
## [72,] 7.612678e-01 0.2387322
## [73,] 7.524040e-01 0.2475960
## [74,] 7.463795e-01 0.2536205
## [75,] 5.602349e-01 0.4397651
## [76,] 2.796344e-01 0.7203656
## [77,] 4.280775e-02 0.9571922
## [78,] 1.784416e-04 0.9998216
## [79,] 1.292124e-08 1.0000000
## [80,] 5.026816e-12 1.0000000
## [81,] 1.777207e-11 1.0000000
## [82,] 4.451568e-10 1.0000000
## [83,] 2.056113e-07 0.9999998
## [84,] 6.929969e-03 0.9930700
## [85,] 1.703407e-01 0.8296593
## [86,] 7.211427e-01 0.2788573
## [87,] 7.463795e-01 0.2536205
## [88,] 7.411749e-01 0.2588251
## [89,] 5.791938e-01 0.4208062
## [90,] 6.298322e-01 0.3701678
## [91,] 6.584001e-01 0.3415999
## [92,] 6.139995e-01 0.3860005
## [93,] 4.030592e-01 0.5969408
## [94,] 1.186362e-01 0.8813638
## [95,] 1.808509e-02 0.9819149
## [96,] 4.602654e-03 0.9953973
## [97,] 8.457835e-03 0.9915422
## [98,] 6.147564e-04 0.9993852
## [99,] 1.028504e-02 0.9897150
## [100,] 1.345468e-01 0.8654532
## [101,] 5.193427e-01 0.4806573
## [102,] 7.411749e-01 0.2588251
## [103,] 7.508910e-01 0.2491090
## [104,] 7.604738e-01 0.2395262
## [105,] 7.038069e-01 0.2961931
## [106,] 5.971197e-01 0.4028803
## [107,] 7.128943e-01 0.2871057
## [108,] 7.604738e-01 0.2395262
## [109,] 7.559988e-01 0.2440012
## [110,] 7.644376e-01 0.2355624
## [111,] 4.275060e-01 0.5724940
## [112,] 1.040688e-01 0.8959312
## [113,] 1.504055e-02 0.9849595
## [114,] 2.300650e-04 0.9997699
## [115,] 2.300650e-04 0.9997699
## [116,] 2.166151e-02 0.9783385
## [117,] 3.633229e-02 0.9636677
## [118,] 1.901316e-01 0.8098684
## [119,] 6.829807e-01 0.3170193
## [120,] 6.139995e-01 0.3860005
## [121,] 6.829807e-01 0.3170193
## [122,] 6.829807e-01 0.3170193
## [123,] 6.711754e-01 0.3288246
## [124,] 6.298322e-01 0.3701678
## [125,] 5.971197e-01 0.4028803
## [126,] 5.402702e-01 0.4597298
## [127,] 4.514858e-01 0.5485142
## [128,] 3.782998e-01 0.6217002
## [129,] 3.038786e-01 0.6961214
## [130,] 9.082929e-02 0.9091707
## [131,] 1.703407e-01 0.8296593
## [132,] 2.796344e-01 0.7203656
## [133,] 5.971197e-01 0.4028803
## [134,] 7.285850e-01 0.2714150
## [135,] 7.038069e-01 0.2961931
## [136,] 7.285850e-01 0.2714150
## [137,] 6.584001e-01 0.3415999
## [138,] 6.446267e-01 0.3553733
## [139,] 4.275060e-01 0.5724940
## [140,] 2.110794e-01 0.7889206
## [141,] 2.330724e-01 0.7669276
## [142,] 6.817692e-02 0.9318231
## [143,] 1.784416e-04 0.9998216
## [144,] 1.050277e-07 0.9999999
## [145,] 6.559042e-10 1.0000000
## [146,] 5.293778e-08 0.9999999
## [147,] 1.423986e-06 0.9999986
## [148,] 7.794074e-04 0.9992206
## [149,] 7.211427e-01 0.2788573
## [150,] 7.547315e-01 0.2452685
## [151,] 7.285850e-01 0.2714150
## [152,] 7.644376e-01 0.2355624
## [153,] 7.644376e-01 0.2355624
## [154,] 7.128943e-01 0.2871057
## [155,] 7.352526e-01 0.2647474
## [156,] 7.645499e-01 0.2354501
## [157,] 7.481457e-01 0.2518543
## [158,] 6.938469e-01 0.3061531
## [159,] 1.504055e-02 0.9849595
## [160,] 1.240178e-03 0.9987598
## [161,] 2.072021e-05 0.9999793
## [162,] 1.169817e-05 0.9999883
## [163,] 6.516958e-06 0.9999935
## [164,] 2.072021e-05 0.9999793
## [165,] 1.556443e-03 0.9984436
## [166,] 1.517926e-01 0.8482074
## [167,] 5.602349e-01 0.4397651
## [168,] 6.446267e-01 0.3553733
## [169,] 7.038069e-01 0.2961931
## [170,] 7.559988e-01 0.2440012
## [171,] 7.432030e-01 0.2567970
## [172,] 7.481457e-01 0.2518543
## [173,] 7.411749e-01 0.2588251
## [174,] 2.796344e-01 0.7203656
## [175,] 1.040688e-01 0.8959312
## [176,] 9.082929e-02 0.9091707
## [177,] 3.633229e-02 0.9636677
## [178,] 5.657726e-03 0.9943423
## [179,] 1.028504e-02 0.9897150
## [180,] 4.602654e-03 0.9953973
## [181,] 7.888266e-02 0.9211173
## [182,] 7.463795e-01 0.2536205
## [183,] 7.645499e-01 0.2354501
## [184,] 6.938469e-01 0.3061531
## [185,] 1.345468e-01 0.8654532
## [186,] 1.901316e-01 0.8098684
## [187,] 2.796344e-01 0.7203656
## [188,] 2.330724e-01 0.7669276
## [189,] 3.533964e-01 0.6466036
## [190,] 9.082929e-02 0.9091707
## [191,] 2.300650e-04 0.9997699
## [192,] 8.160466e-05 0.9999184
## [193,] 2.300650e-04 0.9997699
## [194,] 4.839883e-06 0.9999952
## [195,] 1.379393e-04 0.9998621
## [196,] 6.298322e-01 0.3701678
## [197,] 7.352526e-01 0.2647474
## [198,] 6.446267e-01 0.3553733
## [199,] 7.644376e-01 0.2355624
## [200,] 5.791938e-01 0.4208062
## [201,] 6.584001e-01 0.3415999
## [202,] 6.446267e-01 0.3553733
## [203,] 6.298322e-01 0.3701678
## [204,] 4.030592e-01 0.5969408
## [205,] 6.817692e-02 0.9318231
## [206,] 3.633229e-02 0.9636677
## [207,] 3.633229e-02 0.9636677
## [208,] 1.504055e-02 0.9849595
## [209,] 1.379393e-04 0.9998621
## [210,] 3.038786e-01 0.6961214
## [211,] 5.791938e-01 0.4208062
## [212,] 1.901316e-01 0.8098684
## [213,] 2.110794e-01 0.7889206
## [214,] 4.514858e-01 0.5485142
## [215,] 6.584001e-01 0.3415999
## [216,] 7.637239e-01 0.2362761
## [217,] 7.640612e-01 0.2359388
## [218,] 7.481457e-01 0.2518543
## [219,] 7.524040e-01 0.2475960
## [220,] 7.629691e-01 0.2370309
## [221,] 7.612678e-01 0.2387322
## [222,] 6.139995e-01 0.3860005
## [223,] 7.508910e-01 0.2491090
## [224,] 7.285850e-01 0.2714150
## [225,] 7.463795e-01 0.2536205
## [226,] 7.547315e-01 0.2452685
## [227,] 7.629691e-01 0.2370309
## [228,] 2.110794e-01 0.7889206
## [229,] 3.782998e-01 0.6217002
## [230,] 6.711754e-01 0.3288246
## [231,] 7.211427e-01 0.2788573
## [232,] 6.584001e-01 0.3415999
## [233,] 4.514858e-01 0.5485142
## [234,] 6.298322e-01 0.3701678
## [235,] 4.030592e-01 0.5969408
## [236,] 7.240172e-01 0.2759828
## [237,] 7.645499e-01 0.2354501
## [238,] 7.128943e-01 0.2871057
## [239,] 7.579204e-01 0.2420796
## [240,] 5.193427e-01 0.4806573
## [241,] 7.604738e-01 0.2395262
## [242,] 5.791938e-01 0.4208062
## [243,] 7.038069e-01 0.2961931
## [244,] 7.629691e-01 0.2370309
## [245,] 2.110794e-01 0.7889206
## [246,] 4.975131e-01 0.5024869
## [247,] 1.028504e-02 0.9897150
## [248,] 2.796344e-01 0.7203656
## [249,] 1.186362e-01 0.8813638
## [250,] 2.796344e-01 0.7203656
## [251,] 7.463795e-01 0.2536205
## [252,] 4.975131e-01 0.5024869
## [253,] 9.082929e-02 0.9091707
## [254,] 1.050277e-07 0.9999999
## [255,] 2.166151e-02 0.9783385
## [256,] 3.285277e-01 0.6714723
## [257,] 5.602349e-01 0.4397651
## [258,] 6.829807e-01 0.3170193
## [259,] 6.298322e-01 0.3701678
## [260,] 7.604738e-01 0.2395262
## [261,] 7.038069e-01 0.2961931
## [262,] 7.629691e-01 0.2370309
## [263,] 7.524040e-01 0.2475960
## [264,] 7.128943e-01 0.2871057
## [265,] 7.311663e-01 0.2688337
## [266,] 7.285850e-01 0.2714150
## [267,] 7.481457e-01 0.2518543
## [268,] 7.411749e-01 0.2588251
## [269,] 4.748611e-01 0.5251389
## [270,] 7.211427e-01 0.2788573
## [271,] 6.938469e-01 0.3061531
## [272,] 7.038069e-01 0.2961931
## [273,] 2.330724e-01 0.7669276
## [274,] 9.082929e-02 0.9091707
## [275,] 7.311663e-01 0.2688337
## [276,] 4.748611e-01 0.5251389
## [277,] 7.524040e-01 0.2475960
## [278,] 7.508910e-01 0.2491090
## [279,] 7.375520e-01 0.2624480
## [280,] 7.629691e-01 0.2370309
## [281,] 9.082929e-02 0.9091707
## [282,] 7.352526e-01 0.2647474
## [283,] 4.748611e-01 0.5251389
## [284,] 7.160739e-01 0.2839261
## [285,] 7.604738e-01 0.2395262
## [286,] 5.791938e-01 0.4208062
## [287,] 6.632908e-01 0.3367092
## [288,] 9.848260e-04 0.9990152
## [289,] 7.645499e-01 0.2354501
## [290,] 6.446267e-01 0.3553733
## [291,] 7.559988e-01 0.2440012
## [292,] 7.612678e-01 0.2387322
## [293,] 6.446267e-01 0.3553733
## [294,] 6.871506e-01 0.3128494
## [295,] 7.285850e-01 0.2714150
## [296,] 6.976742e-01 0.3023258
## [297,] 5.478482e-01 0.4521518
## [298,] 7.160739e-01 0.2839261
## [299,] 7.240172e-01 0.2759828
## [300,] 3.285277e-01 0.6714723
## [301,] 6.035520e-01 0.3964480
## [302,] 5.791938e-01 0.4208062
## [303,] 7.589484e-01 0.2410516
## [304,] 7.240172e-01 0.2759828
## [305,] 6.711754e-01 0.3288246
## [306,] 7.481457e-01 0.2518543
## [307,] 1.186362e-01 0.8813638
## [308,] 6.584001e-01 0.3415999
## [309,] 1.808509e-02 0.9819149
## [310,] 4.748611e-01 0.5251389
## [311,] 7.203732e-02 0.9279627
## [312,] 6.711754e-01 0.3288246
## [313,] 8.319990e-02 0.9168001
## [314,] 5.971197e-01 0.4028803
## [315,] 7.624049e-01 0.2375951
## [316,] 7.375520e-01 0.2624480
## [317,] 6.711754e-01 0.3288246
## [318,] 6.035520e-01 0.3964480
## [319,] 3.038786e-01 0.6961214
## [320,] 1.901316e-01 0.8098684
## [321,] 5.021764e-02 0.9497824
## [322,] 1.040043e-06 0.9999990
## [323,] 4.030592e-01 0.5969408
## [324,] 3.070540e-02 0.9692946
## [325,] 7.432030e-01 0.2567970
## [326,] 5.791938e-01 0.4208062
## [327,] 2.796344e-01 0.7203656
## [328,] 7.547315e-01 0.2452685
## [329,] 5.657726e-03 0.9943423
## [330,] 4.122425e-01 0.5877575
## [331,] 5.402702e-01 0.4597298
## [332,] 5.478482e-01 0.4521518
## [333,] 7.375520e-01 0.2624480
## [334,] 9.082929e-02 0.9091707
## [335,] 7.612678e-01 0.2387322
## [336,] 2.584241e-02 0.9741576
## [337,] 7.463795e-01 0.2536205
## [338,] 5.021764e-02 0.9497824
## [339,] 2.330724e-01 0.7669276
## [340,] 7.481457e-01 0.2518543
## [341,] 3.070540e-02 0.9692946
## [342,] 6.035520e-01 0.3964480
## [343,] 7.637239e-01 0.2362761
## [344,] 6.035520e-01 0.3964480
## [345,] 7.481457e-01 0.2518543
## [346,] 6.139995e-01 0.3860005
## [347,] 1.775970e-01 0.8224030
## [348,] 7.559988e-01 0.2440012
## [349,] 1.093573e-01 0.8906427
## [350,] 7.644376e-01 0.2355624
## [351,] 4.975131e-01 0.5024869
## [352,] 7.612678e-01 0.2387322
## [353,] 1.345468e-01 0.8654532
## [354,] 7.589484e-01 0.2410516
## [355,] 2.166151e-02 0.9783385
## [356,] 5.860163e-01 0.4139837
## [357,] 7.629691e-01 0.2370309
## [358,] 6.829807e-01 0.3170193
## [359,] 7.240172e-01 0.2759828
## [360,] 7.637239e-01 0.2362761
## [361,] 7.579204e-01 0.2420796
## [362,] 3.285277e-01 0.6714723
## [363,] 7.640612e-01 0.2359388
## [364,] 7.579204e-01 0.2420796
## [365,] 5.602349e-01 0.4397651
## [366,] 7.352526e-01 0.2647474
## [367,] 3.533964e-01 0.6466036
## [368,] 7.637239e-01 0.2362761
## [369,] 7.508910e-01 0.2491090
## [370,] 7.579204e-01 0.2420796
## [371,] 6.584001e-01 0.3415999
## [372,] 7.352526e-01 0.2647474
## [373,] 6.829807e-01 0.3170193
## [374,] 6.711754e-01 0.3288246
## [375,] 7.128943e-01 0.2871057
## [376,] 5.674412e-01 0.4325588
## [377,] 7.645499e-01 0.2354501
## [378,] 4.030592e-01 0.5969408
## [379,] 3.070540e-02 0.9692946
## [380,] 1.946710e-03 0.9980533
## [381,] 1.040688e-01 0.8959312
## [382,] 4.602654e-03 0.9953973
## [383,] 1.471973e-07 0.9999999
## [384,] 6.817692e-02 0.9318231
## [385,] 1.240178e-03 0.9987598
## [386,] 1.186362e-01 0.8813638
## [387,] 7.888266e-02 0.9211173
## [388,] 1.050277e-07 0.9999999
## [389,] 4.332574e-09 1.0000000
## [390,] 4.280775e-02 0.9571922
## [391,] 7.604738e-01 0.2395262
## [392,] 7.640612e-01 0.2359388
## [393,] 7.604738e-01 0.2395262
## [394,] 9.082929e-02 0.9091707
## [395,] 1.946710e-03 0.9980533
## [396,] 6.139995e-01 0.3860005
## [397,] 7.604738e-01 0.2395262
## [398,] 7.629691e-01 0.2370309
## [399,] 7.038069e-01 0.2961931
## [400,] 7.547315e-01 0.2452685
## [401,] 7.508910e-01 0.2491090
## [402,] 4.602654e-03 0.9953973
## [403,] 2.796344e-01 0.7203656
## [404,] 7.524040e-01 0.2475960
## [405,] 7.579204e-01 0.2420796
## [406,] 7.579204e-01 0.2420796
## [407,] 2.559756e-01 0.7440244
## [408,] 5.791938e-01 0.4208062
## [409,] 7.604738e-01 0.2395262
## [410,] 6.757001e-01 0.3242999
## [411,] 7.640612e-01 0.2359388
## [412,] 7.463795e-01 0.2536205
## [413,] 7.644376e-01 0.2355624
## [414,] 2.110794e-01 0.7889206
## [415,] 4.975131e-01 0.5024869
## [416,] 7.624049e-01 0.2375951
## [417,] 7.508910e-01 0.2491090
## [418,] 7.624049e-01 0.2375951
## [419,] 4.748611e-01 0.5251389
## [420,] 7.352526e-01 0.2647474
## [421,] 7.128943e-01 0.2871057
## [422,] 4.763620e-05 0.9999524
## [423,] 7.432030e-01 0.2567970
## [424,] 6.139995e-01 0.3860005
## [425,] 6.035520e-01 0.3964480
## [426,] 7.128943e-01 0.2871057
## [427,] 7.211427e-01 0.2788573
## [428,] 7.524040e-01 0.2475960
## [429,] 2.584241e-02 0.9741576
## [430,] 7.463795e-01 0.2536205
## [431,] 1.504055e-02 0.9849595
## [432,] 7.285850e-01 0.2714150
## [433,] 1.345468e-01 0.8654532
## [434,] 8.160466e-05 0.9999184
## [435,] 2.300650e-04 0.9997699
## [436,] 1.240178e-03 0.9987598
## [437,] 7.311663e-01 0.2688337
## [438,] 6.711754e-01 0.3288246
## [439,] 7.604738e-01 0.2395262
## [440,] 5.402702e-01 0.4597298
## [441,] 2.743837e-05 0.9999726
## [442,] 7.589484e-01 0.2410516
## [443,] 1.901316e-01 0.8098684
## [444,] 5.478482e-01 0.4521518
## [445,] 5.674412e-01 0.4325588
## [446,] 9.082929e-02 0.9091707
## [447,] 1.901316e-01 0.8098684
## [448,] 3.070540e-02 0.9692946
## [449,] 4.275060e-01 0.5724940
## [450,] 3.786111e-04 0.9996214
## [451,] 1.379393e-04 0.9998621
## [452,] 6.298322e-01 0.3701678
## [453,] 1.517926e-01 0.8482074
## [454,] 6.632908e-01 0.3367092
## [455,] 6.829807e-01 0.3170193
## [456,] 7.160739e-01 0.2839261
## [457,] 7.612678e-01 0.2387322
## [458,] 6.446267e-01 0.3553733
## [459,] 6.200400e-01 0.3799600
## [460,] 7.612678e-01 0.2387322
## [461,] 7.524040e-01 0.2475960
## [462,] 6.711754e-01 0.3288246
## [463,] 5.193427e-01 0.4806573
## [464,] 7.629691e-01 0.2370309
## [465,] 1.040688e-01 0.8959312
## [466,] 7.640612e-01 0.2359388
## [467,] 2.559756e-01 0.7440244
## [468,] 7.038069e-01 0.2961931
## [469,] 7.547315e-01 0.2452685
## [470,] 1.808509e-02 0.9819149
## [471,] 3.378078e-01 0.6621922
## [472,] 7.640612e-01 0.2359388
## [473,] 3.130548e-01 0.6869452
## [474,] 6.976742e-01 0.3023258
## [475,] 7.463795e-01 0.2536205
## [476,] 5.860163e-01 0.4139837
## [477,] 2.166151e-02 0.9783385
## [478,] 6.446267e-01 0.3553733
## [479,] 5.021764e-02 0.9497824
## [480,] 9.848260e-04 0.9990152
## [481,] 4.602654e-03 0.9953973
## [482,] 6.147564e-04 0.9993852
## [483,] 4.280775e-02 0.9571922
## [484,] 1.946710e-03 0.9980533
## [485,] 5.193427e-01 0.4806573
## [486,] 7.559988e-01 0.2440012
## [487,] 7.644376e-01 0.2355624
## [488,] 7.160739e-01 0.2839261
## [489,] 1.703407e-01 0.8296593
## [490,] 5.791938e-01 0.4208062
## [491,] 1.040688e-01 0.8959312
## [492,] 3.731174e-03 0.9962688
## [493,] 6.829807e-01 0.3170193
## [494,] 3.782998e-01 0.6217002
## [495,] 4.030592e-01 0.5969408
## [496,] 3.070540e-02 0.9692946
## [497,] 2.426508e-03 0.9975735
## [498,] 4.030592e-01 0.5969408
## [499,] 6.829807e-01 0.3170193
## [500,] 6.871506e-01 0.3128494
## [501,] 7.629691e-01 0.2370309
## [502,] 7.624049e-01 0.2375951
## [503,] 6.976742e-01 0.3023258
## [504,] 7.604738e-01 0.2395262
## [505,] 7.240172e-01 0.2759828
## [506,] 7.624049e-01 0.2375951
## [507,] 6.498935e-01 0.3501065
## [508,] 7.640612e-01 0.2359388
## [509,] 6.446267e-01 0.3553733
## [510,] 7.612678e-01 0.2387322
## [511,] 7.612678e-01 0.2387322
## [512,] 7.128943e-01 0.2871057
##
## $all.loglik
## [1] -142.7219 327.2409 333.5643 335.1153 336.3855 337.5855 338.7462
## [8] 339.8998 341.0779 342.2935 343.5331 344.7597 345.9273 346.9948
## [15] 347.9367 348.7448 349.4244 349.9889 350.4548 350.8385 351.1545
## [22] 351.4155 351.6316 351.8111 351.9608 352.0861 352.1915 352.2803
## [29] 352.3556 352.4196 352.4741 352.5209 352.5610 352.5956 352.6255
## [36] 352.6514 352.6739 352.6935 352.7106 352.7256 352.7388 352.7504
## [43] 352.7606 352.7696 352.7776 352.7846 352.7909 352.7965 352.8014
## [50] 352.8058 352.8098 352.8133 352.8164 352.8193 352.8218 352.8241
## [57] 352.8261 352.8279 352.8296 352.8310 352.8324 352.8336 352.8347
## [64] 352.8356 352.8365 352.8373 352.8380 352.8387 352.8393 352.8398
## [71] 352.8403 352.8408 352.8412 352.8415 352.8419 352.8422 352.8424
## [78] 352.8427 352.8429 352.8431 352.8433 352.8435 352.8436 352.8438
## [85] 352.8439 352.8440 352.8441 352.8442 352.8443 352.8444 352.8444
## [92] 352.8445 352.8446 352.8446 352.8447 352.8447 352.8448 352.8448
## [99] 352.8448 352.8449 352.8449 352.8449 352.8449 352.8450 352.8450
## [106] 352.8450 352.8450 352.8450 352.8451 352.8451 352.8451 352.8451
## [113] 352.8451 352.8451 352.8451 352.8451 352.8451 352.8451 352.8451
## [120] 352.8451 352.8452 352.8452 352.8452 352.8452 352.8452 352.8452
## [127] 352.8452 352.8452 352.8452 352.8452 352.8452 352.8452 352.8452
## [134] 352.8452 352.8452 352.8452 352.8452 352.8452 352.8452 352.8452
## [141] 352.8452 352.8452 352.8452 352.8452 352.8452 352.8452 352.8452
## [148] 352.8452 352.8452 352.8452 352.8452 352.8452 352.8452 352.8452
## [155] 352.8452 352.8452 352.8452 352.8452 352.8452 352.8452 352.8452
## [162] 352.8452 352.8452 352.8452 352.8452 352.8452 352.8452 352.8452
## [169] 352.8452 352.8452 352.8452 352.8452 352.8452 352.8452 352.8452
## [176] 352.8452 352.8452 352.8452 352.8452 352.8452 352.8452 352.8452
## [183] 352.8452 352.8452 352.8452 352.8452 352.8452 352.8452 352.8452
## [190] 352.8452 352.8452
##
## $restarts
## [1] 0
##
## $ft
## [1] "normalmixEM"
##
## attr(,"class")
## [1] "mixEM"
# Extract mean and variance for each mode
mean_mode1 <- fit_result$mu[1]
print(mean_mode1)
## [1] 0.3411211
variance_mode1 <- fit_result$sigma[1]^2
mean_mode2 <- fit_result$mu[2]
print(mean_mode2)
## [1] 0.4779654
variance_mode2 <- fit_result$sigma[2]^2
# Outlier detection
# Calculate lower and upper bounds for 0.001 probability limits
lower_limit <- qnorm(0.001, mean_mode1, sqrt(variance_mode1))
print(lower_limit)
## [1] 0.1533436
upper_limit <- qnorm(0.999, mean_mode2, sqrt(variance_mode2))
print(upper_limit)
## [1] 0.8988362
for(i in 1:512){
for(j in 1:length(img[i,])){
# Paint black outliers
if(part2_img[i,j] > upper_limit | part2_img[i,j] < lower_limit){
part2_img[i,j] = 0
}
}
}
par(mfrow = c(1,2))
plot(NA,xlim=c(0,nrow(img)),ylim=c(0,ncol(img)),xlab="Horizontal",ylab="Vertical")
rasterImage(img,0,0,nrow(img),ncol(img))
plot(NA,xlim=c(0,nrow(part2_img)),ylim=c(0,ncol(part2_img)),xlab="Horizontal",ylab="Vertical")
rasterImage(part2_img,0,0,nrow(part2_img),ncol(part2_img))
Clearly, assumption that the row’s distribution is same didn’t hold.
# Part 2.2
# Assuming all the columns have the same distribution of pixels
column1 = img[,1]
column_img = img
# Display the distribution of the column
hist(column1, main = "Pixel Value Histogram", xlab = "Pixel Value", ylab = "Frequency", col = "lightblue", border = "black")
# Fit the pixel values to a bimodal distribution
fit_result <- normalmixEM(column1, k = 2) # 'k' specifies the number of components in the mixture model
## number of iterations= 66
fit_result
## $x
## [1] 0.7490196 0.7882353 0.8117647 0.8078431 0.8196078 0.8156863 0.7019608
## [8] 0.5372549 0.4470588 0.3529412 0.3176471 0.3450980 0.3647059 0.3921569
## [15] 0.4431373 0.4745098 0.3725490 0.3921569 0.4431373 0.3764706 0.3647059
## [22] 0.4274510 0.6392157 0.7450980 0.8352941 0.8392157 0.7960784 0.7960784
## [29] 0.7254902 0.5450980 0.4313725 0.3843137 0.3647059 0.4235294 0.3960784
## [36] 0.3921569 0.4745098 0.4039216 0.4196078 0.3960784 0.4313725 0.4941176
## [43] 0.4549020 0.3803922 0.5176471 0.7215686 0.7725490 0.7803922 0.7725490
## [50] 0.8352941 0.8117647 0.7176471 0.5647059 0.4156863 0.3647059 0.3490196
## [57] 0.4235294 0.4823529 0.4235294 0.4235294 0.4901961 0.4745098 0.4509804
## [64] 0.4549020 0.3960784 0.3882353 0.3490196 0.4549020 0.5921569 0.6823529
## [71] 0.7764706 0.7529412 0.7921569 0.7647059 0.6235294 0.5490196 0.4588235
## [78] 0.3490196 0.3803922 0.4196078 0.4000000 0.4078431 0.4509804 0.4549020
## [85] 0.4705882 0.5137255 0.4980392 0.4784314 0.3882353 0.4117647 0.4666667
## [92] 0.6941176 0.7921569 0.7647059 0.8039216 0.7058824 0.7372549 0.6235294
## [99] 0.4941176 0.3882353 0.3843137 0.3960784 0.3607843 0.3960784 0.4470588
## [106] 0.4431373 0.4627451 0.4745098 0.5058824 0.4392157 0.4509804 0.3921569
## [113] 0.3607843 0.5490196 0.6823529 0.7098039 0.7215686 0.7098039 0.7058824
## [120] 0.7372549 0.6352941 0.4431373 0.3607843 0.4117647 0.3725490 0.3843137
## [127] 0.5058824 0.5137255 0.4901961 0.5098039 0.4941176 0.5058824 0.5372549
## [134] 0.4901961 0.4745098 0.5490196 0.6901961 0.7803922 0.7411765 0.7019608
## [141] 0.6941176 0.7607843 0.6745098 0.5921569 0.4274510 0.3803922 0.3058824
## [148] 0.3647059 0.4274510 0.4745098 0.5294118 0.4509804 0.4980392 0.4901961
## [155] 0.5254902 0.5294118 0.4431373 0.4117647 0.5411765 0.7137255 0.7647059
## [162] 0.7450980 0.7372549 0.7490196 0.7647059 0.7411765 0.6235294 0.4862745
## [169] 0.4000000 0.3450980 0.4039216 0.3921569 0.3921569 0.4784314 0.4980392
## [176] 0.5137255 0.5333333 0.4941176 0.5254902 0.4313725 0.3882353 0.4745098
## [183] 0.6666667 0.6666667 0.7254902 0.7215686 0.7254902 0.6980392 0.6823529
## [190] 0.5764706 0.4000000 0.3568627 0.3882353 0.4666667 0.4039216 0.4705882
## [197] 0.5764706 0.4666667 0.5137255 0.4549020 0.4823529 0.4235294 0.4313725
## [204] 0.3803922 0.4823529 0.6470588 0.6156863 0.6313725 0.6431373 0.6941176
## [211] 0.5960784 0.4196078 0.4039216 0.4156863 0.3411765 0.3490196 0.3882353
## [218] 0.4313725 0.4666667 0.5137255 0.5254902 0.6000000 0.5372549 0.5098039
## [225] 0.4156863 0.4392157 0.3803922 0.4039216 0.5176471 0.6039216 0.6549020
## [232] 0.6392157 0.6431373 0.5843137 0.5294118 0.4784314 0.4627451 0.4039216
## [239] 0.3411765 0.4000000 0.4588235 0.5607843 0.6196078 0.6392157 0.6156863
## [246] 0.5921569 0.5725490 0.4862745 0.4235294 0.3647059 0.3843137 0.5254902
## [253] 0.6039216 0.6235294 0.6549020 0.6117647 0.5450980 0.5372549 0.5411765
## [260] 0.4666667 0.4156863 0.4431373 0.5137255 0.6156863 0.6784314 0.6470588
## [267] 0.6196078 0.5960784 0.6313725 0.5960784 0.4588235 0.4274510 0.3647059
## [274] 0.3882353 0.5137255 0.5607843 0.5686275 0.5725490 0.5215686 0.5647059
## [281] 0.5450980 0.4431373 0.4352941 0.3529412 0.4470588 0.4549020 0.4549020
## [288] 0.6235294 0.6235294 0.7215686 0.6901961 0.6352941 0.5411765 0.4392157
## [295] 0.4274510 0.3803922 0.4352941 0.4823529 0.5019608 0.5254902 0.5058824
## [302] 0.4862745 0.4980392 0.4549020 0.4196078 0.4588235 0.3254902 0.3529412
## [309] 0.4705882 0.6666667 0.7529412 0.7294118 0.7764706 0.7450980 0.6823529
## [316] 0.6196078 0.4196078 0.3607843 0.3803922 0.4588235 0.5215686 0.4627451
## [323] 0.4235294 0.4784314 0.5137255 0.5294118 0.5176471 0.4117647 0.3882353
## [330] 0.4470588 0.4627451 0.6039216 0.6823529 0.7686275 0.7686275 0.7333333
## [337] 0.7058824 0.7019608 0.5568627 0.4313725 0.3921569 0.3647059 0.3882353
## [344] 0.4313725 0.5058824 0.5098039 0.4509804 0.4784314 0.4823529 0.4392157
## [351] 0.4470588 0.3882353 0.3529412 0.4235294 0.5764706 0.6470588 0.7450980
## [358] 0.7803922 0.7882353 0.6901961 0.6901961 0.6274510 0.4745098 0.3764706
## [365] 0.3960784 0.4078431 0.4117647 0.4705882 0.5254902 0.4470588 0.4039216
## [372] 0.4156863 0.3921569 0.4431373 0.4784314 0.3490196 0.4431373 0.6823529
## [379] 0.6666667 0.7803922 0.7529412 0.7254902 0.7960784 0.7058824 0.6117647
## [386] 0.4666667 0.3607843 0.3960784 0.3960784 0.4588235 0.5607843 0.4588235
## [393] 0.4392157 0.4235294 0.4039216 0.4274510 0.4470588 0.3764706 0.3294118
## [400] 0.3725490 0.4980392 0.7176471 0.7450980 0.7686275 0.8078431 0.8235294
## [407] 0.8470588 0.7215686 0.5372549 0.3294118 0.3411765 0.3686275 0.4196078
## [414] 0.5176471 0.4627451 0.4313725 0.4078431 0.4196078 0.4196078 0.4039216
## [421] 0.4156863 0.3647059 0.3294118 0.4549020 0.6588235 0.8196078 0.7882353
## [428] 0.8000000 0.8313725 0.7686275 0.6470588 0.4039216 0.3529412 0.4509804
## [435] 0.4156863 0.3764706 0.4039216 0.4000000 0.4196078 0.4588235 0.4901961
## [442] 0.4274510 0.3960784 0.4156863 0.4431373 0.5215686 0.6627451 0.7803922
## [449] 0.8235294 0.8274510 0.8000000 0.7843137 0.7529412 0.6196078 0.4431373
## [456] 0.3450980 0.3647059 0.3960784 0.3725490 0.4039216 0.4313725 0.4000000
## [463] 0.3921569 0.3882353 0.3882353 0.3725490 0.3882353 0.4000000 0.4078431
## [470] 0.5176471 0.6980392 0.8196078 0.7960784 0.8274510 0.7882353 0.7058824
## [477] 0.5686275 0.4470588 0.4274510 0.4156863 0.3607843 0.3450980 0.3882353
## [484] 0.4549020 0.3647059 0.4117647 0.4313725 0.3921569 0.3960784 0.4196078
## [491] 0.4117647 0.3921569 0.4431373 0.6549020 0.8352941 0.8078431 0.7843137
## [498] 0.7803922 0.7725490 0.5411765 0.3960784 0.3568627 0.4000000 0.3960784
## [505] 0.3411765 0.3450980 0.4549020 0.4431373 0.4352941 0.3921569 0.4000000
## [512] 0.3882353
##
## $lambda
## [1] 0.6552366 0.3447634
##
## $mu
## [1] 0.4333947 0.6992993
##
## $sigma
## [1] 0.05673084 0.08565956
##
## $loglik
## [1] 382.63
##
## $posterior
## comp.1 comp.2
## [1,] 6.450755e-07 0.9999993549
## [2,] 1.572293e-08 0.9999999843
## [3,] 1.488564e-09 0.9999999985
## [4,] 2.219768e-09 0.9999999978
## [5,] 6.640368e-10 0.9999999993
## [6,] 9.955482e-10 0.9999999990
## [7,] 3.903978e-05 0.9999609602
## [8,] 7.627259e-01 0.2372741480
## [9,] 9.953247e-01 0.0046752756
## [10,] 9.997317e-01 0.0002682672
## [11,] 9.998634e-01 0.0001365973
## [12,] 9.997734e-01 0.0002266099
## [13,] 9.996474e-01 0.0003525562
## [14,] 9.992675e-01 0.0007324852
## [15,] 9.959738e-01 0.0040261935
## [16,] 9.857246e-01 0.0142753831
## [17,] 9.995713e-01 0.0004286985
## [18,] 9.992675e-01 0.0007324852
## [19,] 9.959738e-01 0.0040261935
## [20,] 9.995254e-01 0.0004746328
## [21,] 9.996474e-01 0.0003525562
## [22,] 9.977274e-01 0.0022726144
## [23,] 5.061120e-03 0.9949388797
## [24,] 9.215326e-07 0.9999990785
## [25,] 1.279563e-10 0.9999999999
## [26,] 8.421053e-11 0.9999999999
## [27,] 7.243328e-09 0.9999999928
## [28,] 7.243328e-09 0.9999999928
## [29,] 5.266659e-06 0.9999947333
## [30,] 6.761211e-01 0.3238788547
## [31,] 9.973884e-01 0.0026116434
## [32,] 9.994135e-01 0.0005864834
## [33,] 9.996474e-01 0.0003525562
## [34,] 9.980172e-01 0.0019828103
## [35,] 9.991781e-01 0.0008218845
## [36,] 9.992675e-01 0.0007324852
## [37,] 9.857246e-01 0.0142753831
## [38,] 9.989569e-01 0.0010430645
## [39,] 9.982655e-01 0.0017345365
## [40,] 9.991781e-01 0.0008218845
## [41,] 9.973884e-01 0.0026116434
## [42,] 9.661088e-01 0.0338911605
## [43,] 9.936473e-01 0.0063527395
## [44,] 9.994731e-01 0.0005268972
## [45,] 9.002439e-01 0.0997560545
## [46,] 7.403627e-06 0.9999925964
## [47,] 7.173719e-08 0.9999999283
## [48,] 3.376517e-08 0.9999999662
## [49,] 7.173719e-08 0.9999999283
## [50,] 1.279563e-10 0.9999999999
## [51,] 1.488564e-09 0.9999999985
## [52,] 1.037979e-05 0.9999896202
## [53,] 4.036835e-01 0.5963164721
## [54,] 9.984786e-01 0.0015213721
## [55,] 9.996474e-01 0.0003525562
## [56,] 9.997538e-01 0.0002462302
## [57,] 9.980172e-01 0.0019828103
## [58,] 9.799447e-01 0.0200553397
## [59,] 9.980172e-01 0.0019828103
## [60,] 9.980172e-01 0.0019828103
## [61,] 9.715966e-01 0.0284034260
## [62,] 9.857246e-01 0.0142753831
## [63,] 9.945571e-01 0.0054429310
## [64,] 9.936473e-01 0.0063527395
## [65,] 9.991781e-01 0.0008218845
## [66,] 9.993454e-01 0.0006545562
## [67,] 9.997538e-01 0.0002462302
## [68,] 9.936473e-01 0.0063527395
## [69,] 1.111147e-01 0.8888853256
## [70,] 1.924830e-04 0.9998075170
## [71,] 4.928209e-08 0.9999999507
## [72,] 4.503450e-07 0.9999995497
## [73,] 1.068608e-08 0.9999999893
## [74,] 1.507856e-07 0.9999998492
## [75,] 1.520298e-02 0.9847970207
## [76,] 6.262445e-01 0.3737554787
## [77,] 9.925667e-01 0.0074332581
## [78,] 9.997538e-01 0.0002462302
## [79,] 9.994731e-01 0.0005268972
## [80,] 9.982655e-01 0.0017345365
## [81,] 9.990753e-01 0.0009246596
## [82,] 9.988202e-01 0.0011797704
## [83,] 9.945571e-01 0.0054429310
## [84,] 9.936473e-01 0.0063527395
## [85,] 9.879163e-01 0.0120837474
## [86,] 9.167008e-01 0.0832992417
## [87,] 9.595008e-01 0.0404991917
## [88,] 9.830977e-01 0.0169022502
## [89,] 9.993454e-01 0.0006545562
## [90,] 9.986621e-01 0.0013379487
## [91,] 9.897477e-01 0.0102522775
## [92,] 7.450195e-05 0.9999254981
## [93,] 1.068608e-08 0.9999999893
## [94,] 1.507856e-07 0.9999998492
## [95,] 3.301283e-09 0.9999999967
## [96,] 2.814665e-05 0.9999718533
## [97,] 1.865588e-06 0.9999981344
## [98,] 1.520298e-02 0.9847970207
## [99,] 9.661088e-01 0.0338911605
## [100,] 9.993454e-01 0.0006545562
## [101,] 9.994135e-01 0.0005864834
## [102,] 9.991781e-01 0.0008218845
## [103,] 9.996790e-01 0.0003210046
## [104,] 9.991781e-01 0.0008218845
## [105,] 9.953247e-01 0.0046752756
## [106,] 9.959738e-01 0.0040261935
## [107,] 9.912809e-01 0.0087191050
## [108,] 9.857246e-01 0.0142753831
## [109,] 9.419748e-01 0.0580251854
## [110,] 9.965238e-01 0.0034761916
## [111,] 9.945571e-01 0.0054429310
## [112,] 9.992675e-01 0.0007324852
## [113,] 9.996790e-01 0.0003210046
## [114,] 6.262445e-01 0.3737554787
## [115,] 1.924830e-04 0.9998075170
## [116,] 2.023857e-05 0.9999797614
## [117,] 7.403627e-06 0.9999925964
## [118,] 2.023857e-05 0.9999797614
## [119,] 2.814665e-05 0.9999718533
## [120,] 1.865588e-06 0.9999981344
## [121,] 6.695961e-03 0.9933040395
## [122,] 9.959738e-01 0.0040261935
## [123,] 9.996790e-01 0.0003210046
## [124,] 9.986621e-01 0.0013379487
## [125,] 9.995713e-01 0.0004286985
## [126,] 9.994135e-01 0.0005864834
## [127,] 9.419748e-01 0.0580251854
## [128,] 9.167008e-01 0.0832992417
## [129,] 9.715966e-01 0.0284034260
## [130,] 9.304785e-01 0.0695215094
## [131,] 9.661088e-01 0.0338911605
## [132,] 9.419748e-01 0.0580251854
## [133,] 7.627259e-01 0.2372741480
## [134,] 9.715966e-01 0.0284034260
## [135,] 9.857246e-01 0.0142753831
## [136,] 6.262445e-01 0.3737554787
## [137,] 1.025052e-04 0.9998974948
## [138,] 3.376517e-08 0.9999999662
## [139,] 1.312943e-06 0.9999986871
## [140,] 3.903978e-05 0.9999609602
## [141,] 7.450195e-05 0.9999254981
## [142,] 2.177309e-07 0.9999997823
## [143,] 3.575579e-04 0.9996424421
## [144,] 1.111147e-01 0.8888853256
## [145,] 9.977274e-01 0.0022726144
## [146,] 9.994731e-01 0.0005268972
## [147,] 9.998855e-01 0.0001144706
## [148,] 9.996474e-01 0.0003525562
## [149,] 9.977274e-01 0.0022726144
## [150,] 9.857246e-01 0.0142753831
## [151,] 8.304236e-01 0.1695764274
## [152,] 9.945571e-01 0.0054429310
## [153,] 9.595008e-01 0.0404991917
## [154,] 9.715966e-01 0.0284034260
## [155,] 8.575494e-01 0.1424506273
## [156,] 8.304236e-01 0.1695764274
## [157,] 9.959738e-01 0.0040261935
## [158,] 9.986621e-01 0.0013379487
## [159,] 7.217550e-01 0.2782449775
## [160,] 1.451333e-05 0.9999854867
## [161,] 1.507856e-07 0.9999998492
## [162,] 9.215326e-07 0.9999990785
## [163,] 1.865588e-06 0.9999981344
## [164,] 6.450755e-07 0.9999993549
## [165,] 1.507856e-07 0.9999998492
## [166,] 1.312943e-06 0.9999986871
## [167,] 1.520298e-02 0.9847970207
## [168,] 9.761552e-01 0.0238447627
## [169,] 9.990753e-01 0.0009246596
## [170,] 9.997734e-01 0.0002266099
## [171,] 9.989569e-01 0.0010430645
## [172,] 9.992675e-01 0.0007324852
## [173,] 9.992675e-01 0.0007324852
## [174,] 9.830977e-01 0.0169022502
## [175,] 9.595008e-01 0.0404991917
## [176,] 9.167008e-01 0.0832992417
## [177,] 7.989105e-01 0.2010895451
## [178,] 9.661088e-01 0.0338911605
## [179,] 8.575494e-01 0.1424506273
## [180,] 9.973884e-01 0.0026116434
## [181,] 9.993454e-01 0.0006545562
## [182,] 9.857246e-01 0.0142753831
## [183,] 6.570252e-04 0.9993429748
## [184,] 6.570252e-04 0.9993429748
## [185,] 5.266659e-06 0.9999947333
## [186,] 7.403627e-06 0.9999925964
## [187,] 5.266659e-06 0.9999947333
## [188,] 5.400341e-05 0.9999459966
## [189,] 1.924830e-04 0.9998075170
## [190,] 2.501118e-01 0.7498881963
## [191,] 9.990753e-01 0.0009246596
## [192,] 9.997069e-01 0.0002930607
## [193,] 9.993454e-01 0.0006545562
## [194,] 9.897477e-01 0.0102522775
## [195,] 9.989569e-01 0.0010430645
## [196,] 9.879163e-01 0.0120837474
## [197,] 2.501118e-01 0.7498881963
## [198,] 9.897477e-01 0.0102522775
## [199,] 9.167008e-01 0.0832992417
## [200,] 9.936473e-01 0.0063527395
## [201,] 9.799447e-01 0.0200553397
## [202,] 9.980172e-01 0.0019828103
## [203,] 9.973884e-01 0.0026116434
## [204,] 9.994731e-01 0.0005268972
## [205,] 9.799447e-01 0.0200553397
## [206,] 2.865156e-03 0.9971348436
## [207,] 2.578185e-02 0.9742181495
## [208,] 8.830676e-03 0.9911693238
## [209,] 3.813690e-03 0.9961863097
## [210,] 7.450195e-05 0.9999254981
## [211,] 8.855083e-02 0.9114491671
## [212,] 9.982655e-01 0.0017345365
## [213,] 9.989569e-01 0.0010430645
## [214,] 9.984786e-01 0.0015213721
## [215,] 9.997909e-01 0.0002091128
## [216,] 9.997538e-01 0.0002462302
## [217,] 9.993454e-01 0.0006545562
## [218,] 9.973884e-01 0.0026116434
## [219,] 9.897477e-01 0.0102522775
## [220,] 9.167008e-01 0.0832992417
## [221,] 8.575494e-01 0.1424506273
## [222,] 7.003218e-02 0.9299678206
## [223,] 7.627259e-01 0.2372741480
## [224,] 9.304785e-01 0.0695215094
## [225,] 9.984786e-01 0.0015213721
## [226,] 9.965238e-01 0.0034761916
## [227,] 9.994731e-01 0.0005268972
## [228,] 9.989569e-01 0.0010430645
## [229,] 9.002439e-01 0.0997560545
## [230,] 5.501237e-02 0.9449876279
## [231,] 1.603178e-03 0.9983968217
## [232,] 5.061120e-03 0.9949388797
## [233,] 3.813690e-03 0.9961863097
## [234,] 1.703222e-01 0.8296778403
## [235,] 8.304236e-01 0.1695764274
## [236,] 9.830977e-01 0.0169022502
## [237,] 9.912809e-01 0.0087191050
## [238,] 9.989569e-01 0.0010430645
## [239,] 9.997909e-01 0.0002091128
## [240,] 9.990753e-01 0.0009246596
## [241,] 9.925667e-01 0.0074332581
## [242,] 4.601977e-01 0.5398022781
## [243,] 1.983811e-02 0.9801618927
## [244,] 5.061120e-03 0.9949388797
## [245,] 2.578185e-02 0.9742181495
## [246,] 1.111147e-01 0.8888853256
## [247,] 2.974699e-01 0.7025300562
## [248,] 9.761552e-01 0.0238447627
## [249,] 9.980172e-01 0.0019828103
## [250,] 9.996474e-01 0.0003525562
## [251,] 9.994135e-01 0.0005864834
## [252,] 8.575494e-01 0.1424506273
## [253,] 5.501237e-02 0.9449876279
## [254,] 1.520298e-02 0.9847970207
## [255,] 1.603178e-03 0.9983968217
## [256,] 3.335904e-02 0.9666409620
## [257,] 6.761211e-01 0.3238788547
## [258,] 7.627259e-01 0.2372741480
## [259,] 7.217550e-01 0.2782449775
## [260,] 9.897477e-01 0.0102522775
## [261,] 9.984786e-01 0.0015213721
## [262,] 9.959738e-01 0.0040261935
## [263,] 9.167008e-01 0.0832992417
## [264,] 2.578185e-02 0.9742181495
## [265,] 2.626983e-04 0.9997373017
## [266,] 2.865156e-03 0.9971348436
## [267,] 1.983811e-02 0.9801618927
## [268,] 8.855083e-02 0.9114491671
## [269,] 8.830676e-03 0.9911693238
## [270,] 8.855083e-02 0.9114491671
## [271,] 9.925667e-01 0.0074332581
## [272,] 9.977274e-01 0.0022726144
## [273,] 9.996474e-01 0.0003525562
## [274,] 9.993454e-01 0.0006545562
## [275,] 9.167008e-01 0.0832992417
## [276,] 4.601977e-01 0.5398022781
## [277,] 3.490048e-01 0.6509951551
## [278,] 2.974699e-01 0.7025300562
## [279,] 8.806765e-01 0.1193235171
## [280,] 4.036835e-01 0.5963164721
## [281,] 6.761211e-01 0.3238788547
## [282,] 9.959738e-01 0.0040261935
## [283,] 9.969909e-01 0.0030091337
## [284,] 9.997317e-01 0.0002682672
## [285,] 9.953247e-01 0.0046752756
## [286,] 9.936473e-01 0.0063527395
## [287,] 9.936473e-01 0.0063527395
## [288,] 1.520298e-02 0.9847970207
## [289,] 1.520298e-02 0.9847970207
## [290,] 7.403627e-06 0.9999925964
## [291,] 1.025052e-04 0.9998974948
## [292,] 6.695961e-03 0.9933040395
## [293,] 7.217550e-01 0.2782449775
## [294,] 9.965238e-01 0.0034761916
## [295,] 9.977274e-01 0.0022726144
## [296,] 9.994731e-01 0.0005268972
## [297,] 9.969909e-01 0.0030091337
## [298,] 9.799447e-01 0.0200553397
## [299,] 9.515453e-01 0.0484547202
## [300,] 8.575494e-01 0.1424506273
## [301,] 9.419748e-01 0.0580251854
## [302,] 9.761552e-01 0.0238447627
## [303,] 9.595008e-01 0.0404991917
## [304,] 9.936473e-01 0.0063527395
## [305,] 9.982655e-01 0.0017345365
## [306,] 9.925667e-01 0.0074332581
## [307,] 9.998442e-01 0.0001557508
## [308,] 9.997317e-01 0.0002682672
## [309,] 9.879163e-01 0.0120837474
## [310,] 6.570252e-04 0.9993429748
## [311,] 4.503450e-07 0.9999995497
## [312,] 3.736462e-06 0.9999962635
## [313,] 4.928209e-08 0.9999999507
## [314,] 9.215326e-07 0.9999990785
## [315,] 1.924830e-04 0.9998075170
## [316,] 1.983811e-02 0.9801618927
## [317,] 9.982655e-01 0.0017345365
## [318,] 9.996790e-01 0.0003210046
## [319,] 9.994731e-01 0.0005268972
## [320,] 9.925667e-01 0.0074332581
## [321,] 8.806765e-01 0.1193235171
## [322,] 9.912809e-01 0.0087191050
## [323,] 9.980172e-01 0.0019828103
## [324,] 9.830977e-01 0.0169022502
## [325,] 9.167008e-01 0.0832992417
## [326,] 8.304236e-01 0.1695764274
## [327,] 9.002439e-01 0.0997560545
## [328,] 9.986621e-01 0.0013379487
## [329,] 9.993454e-01 0.0006545562
## [330,] 9.953247e-01 0.0046752756
## [331,] 9.912809e-01 0.0087191050
## [332,] 5.501237e-02 0.9449876279
## [333,] 1.924830e-04 0.9998075170
## [334,] 1.041441e-07 0.9999998959
## [335,] 1.041441e-07 0.9999998959
## [336,] 2.643752e-06 0.9999973562
## [337,] 2.814665e-05 0.9999718533
## [338,] 3.903978e-05 0.9999609602
## [339,] 5.170844e-01 0.4829155510
## [340,] 9.973884e-01 0.0026116434
## [341,] 9.992675e-01 0.0007324852
## [342,] 9.996474e-01 0.0003525562
## [343,] 9.993454e-01 0.0006545562
## [344,] 9.973884e-01 0.0026116434
## [345,] 9.419748e-01 0.0580251854
## [346,] 9.304785e-01 0.0695215094
## [347,] 9.945571e-01 0.0054429310
## [348,] 9.830977e-01 0.0169022502
## [349,] 9.799447e-01 0.0200553397
## [350,] 9.965238e-01 0.0034761916
## [351,] 9.953247e-01 0.0046752756
## [352,] 9.993454e-01 0.0006545562
## [353,] 9.997317e-01 0.0002682672
## [354,] 9.980172e-01 0.0019828103
## [355,] 2.501118e-01 0.7498881963
## [356,] 2.865156e-03 0.9971348436
## [357,] 9.215326e-07 0.9999990785
## [358,] 3.376517e-08 0.9999999662
## [359,] 1.572293e-08 0.9999999843
## [360,] 1.025052e-04 0.9998974948
## [361,] 1.025052e-04 0.9998974948
## [362,] 1.160716e-02 0.9883928358
## [363,] 9.857246e-01 0.0142753831
## [364,] 9.995254e-01 0.0004746328
## [365,] 9.991781e-01 0.0008218845
## [366,] 9.988202e-01 0.0011797704
## [367,] 9.986621e-01 0.0013379487
## [368,] 9.879163e-01 0.0120837474
## [369,] 8.575494e-01 0.1424506273
## [370,] 9.953247e-01 0.0046752756
## [371,] 9.989569e-01 0.0010430645
## [372,] 9.984786e-01 0.0015213721
## [373,] 9.992675e-01 0.0007324852
## [374,] 9.959738e-01 0.0040261935
## [375,] 9.830977e-01 0.0169022502
## [376,] 9.997538e-01 0.0002462302
## [377,] 9.959738e-01 0.0040261935
## [378,] 1.924830e-04 0.9998075170
## [379,] 6.570252e-04 0.9993429748
## [380,] 3.376517e-08 0.9999999662
## [381,] 4.503450e-07 0.9999995497
## [382,] 5.266659e-06 0.9999947333
## [383,] 7.243328e-09 0.9999999928
## [384,] 2.814665e-05 0.9999718533
## [385,] 3.335904e-02 0.9666409620
## [386,] 9.897477e-01 0.0102522775
## [387,] 9.996790e-01 0.0003210046
## [388,] 9.991781e-01 0.0008218845
## [389,] 9.991781e-01 0.0008218845
## [390,] 9.925667e-01 0.0074332581
## [391,] 4.601977e-01 0.5398022781
## [392,] 9.925667e-01 0.0074332581
## [393,] 9.965238e-01 0.0034761916
## [394,] 9.980172e-01 0.0019828103
## [395,] 9.989569e-01 0.0010430645
## [396,] 9.977274e-01 0.0022726144
## [397,] 9.953247e-01 0.0046752756
## [398,] 9.995254e-01 0.0004746328
## [399,] 9.998330e-01 0.0001669827
## [400,] 9.995713e-01 0.0004286985
## [401,] 9.595008e-01 0.0404991917
## [402,] 1.037979e-05 0.9999896202
## [403,] 9.215326e-07 0.9999990785
## [404,] 1.041441e-07 0.9999998959
## [405,] 2.219768e-09 0.9999999978
## [406,] 4.417301e-10 0.9999999996
## [407,] 3.618105e-11 1.0000000000
## [408,] 7.403627e-06 0.9999925964
## [409,] 7.627259e-01 0.2372741480
## [410,] 9.998330e-01 0.0001669827
## [411,] 9.997909e-01 0.0002091128
## [412,] 9.996118e-01 0.0003882475
## [413,] 9.982655e-01 0.0017345365
## [414,] 9.002439e-01 0.0997560545
## [415,] 9.912809e-01 0.0087191050
## [416,] 9.973884e-01 0.0026116434
## [417,] 9.988202e-01 0.0011797704
## [418,] 9.982655e-01 0.0017345365
## [419,] 9.982655e-01 0.0017345365
## [420,] 9.989569e-01 0.0010430645
## [421,] 9.984786e-01 0.0015213721
## [422,] 9.996474e-01 0.0003525562
## [423,] 9.998330e-01 0.0001669827
## [424,] 9.936473e-01 0.0063527395
## [425,] 1.194137e-03 0.9988058625
## [426,] 6.640368e-10 0.9999999993
## [427,] 1.572293e-08 0.9999999843
## [428,] 4.896581e-09 0.9999999951
## [429,] 1.939062e-10 0.9999999998
## [430,] 1.041441e-07 0.9999998959
## [431,] 2.865156e-03 0.9971348436
## [432,] 9.989569e-01 0.0010430645
## [433,] 9.997317e-01 0.0002682672
## [434,] 9.945571e-01 0.0054429310
## [435,] 9.984786e-01 0.0015213721
## [436,] 9.995254e-01 0.0004746328
## [437,] 9.989569e-01 0.0010430645
## [438,] 9.990753e-01 0.0009246596
## [439,] 9.982655e-01 0.0017345365
## [440,] 9.925667e-01 0.0074332581
## [441,] 9.715966e-01 0.0284034260
## [442,] 9.977274e-01 0.0022726144
## [443,] 9.991781e-01 0.0008218845
## [444,] 9.984786e-01 0.0015213721
## [445,] 9.959738e-01 0.0040261935
## [446,] 8.806765e-01 0.1193235171
## [447,] 8.869875e-04 0.9991130125
## [448,] 3.376517e-08 0.9999999662
## [449,] 4.417301e-10 0.9999999996
## [450,] 2.930602e-10 0.9999999997
## [451,] 4.896581e-09 0.9999999951
## [452,] 2.307192e-08 0.9999999769
## [453,] 4.503450e-07 0.9999995497
## [454,] 1.983811e-02 0.9801618927
## [455,] 9.959738e-01 0.0040261935
## [456,] 9.997734e-01 0.0002266099
## [457,] 9.996474e-01 0.0003525562
## [458,] 9.991781e-01 0.0008218845
## [459,] 9.995713e-01 0.0004286985
## [460,] 9.989569e-01 0.0010430645
## [461,] 9.973884e-01 0.0026116434
## [462,] 9.990753e-01 0.0009246596
## [463,] 9.992675e-01 0.0007324852
## [464,] 9.993454e-01 0.0006545562
## [465,] 9.993454e-01 0.0006545562
## [466,] 9.995713e-01 0.0004286985
## [467,] 9.993454e-01 0.0006545562
## [468,] 9.990753e-01 0.0009246596
## [469,] 9.988202e-01 0.0011797704
## [470,] 9.002439e-01 0.0997560545
## [471,] 5.400341e-05 0.9999459966
## [472,] 6.640368e-10 0.9999999993
## [473,] 7.243328e-09 0.9999999928
## [474,] 2.930602e-10 0.9999999997
## [475,] 1.572293e-08 0.9999999843
## [476,] 2.814665e-05 0.9999718533
## [477,] 3.490048e-01 0.6509951551
## [478,] 9.953247e-01 0.0046752756
## [479,] 9.977274e-01 0.0022726144
## [480,] 9.984786e-01 0.0015213721
## [481,] 9.996790e-01 0.0003210046
## [482,] 9.997734e-01 0.0002266099
## [483,] 9.993454e-01 0.0006545562
## [484,] 9.936473e-01 0.0063527395
## [485,] 9.996474e-01 0.0003525562
## [486,] 9.986621e-01 0.0013379487
## [487,] 9.973884e-01 0.0026116434
## [488,] 9.992675e-01 0.0007324852
## [489,] 9.991781e-01 0.0008218845
## [490,] 9.982655e-01 0.0017345365
## [491,] 9.986621e-01 0.0013379487
## [492,] 9.992675e-01 0.0007324852
## [493,] 9.959738e-01 0.0040261935
## [494,] 1.603178e-03 0.9983968217
## [495,] 1.279563e-10 0.9999999999
## [496,] 2.219768e-09 0.9999999978
## [497,] 2.307192e-08 0.9999999769
## [498,] 3.376517e-08 0.9999999662
## [499,] 7.173719e-08 0.9999999283
## [500,] 7.217550e-01 0.2782449775
## [501,] 9.991781e-01 0.0008218845
## [502,] 9.997069e-01 0.0002930607
## [503,] 9.990753e-01 0.0009246596
## [504,] 9.991781e-01 0.0008218845
## [505,] 9.997909e-01 0.0002091128
## [506,] 9.997734e-01 0.0002266099
## [507,] 9.936473e-01 0.0063527395
## [508,] 9.959738e-01 0.0040261935
## [509,] 9.969909e-01 0.0030091337
## [510,] 9.992675e-01 0.0007324852
## [511,] 9.990753e-01 0.0009246596
## [512,] 9.993454e-01 0.0006545562
##
## $all.loglik
## [1] 235.1725 289.1995 315.0503 349.7271 371.7822 378.8570 380.3885 380.8326
## [9] 381.1169 381.3620 381.5793 381.7699 381.9344 382.0741 382.1910 382.2871
## [17] 382.3651 382.4273 382.4763 382.5145 382.5438 382.5661 382.5829 382.5954
## [25] 382.6048 382.6117 382.6167 382.6204 382.6231 382.6250 382.6264 382.6274
## [33] 382.6282 382.6287 382.6291 382.6293 382.6295 382.6297 382.6298 382.6298
## [41] 382.6299 382.6299 382.6299 382.6300 382.6300 382.6300 382.6300 382.6300
## [49] 382.6300 382.6300 382.6300 382.6300 382.6300 382.6300 382.6300 382.6300
## [57] 382.6300 382.6300 382.6300 382.6300 382.6300 382.6300 382.6300 382.6300
## [65] 382.6300 382.6300 382.6300
##
## $restarts
## [1] 0
##
## $ft
## [1] "normalmixEM"
##
## attr(,"class")
## [1] "mixEM"
# Extract mean and variance for each mode
mean_mode1 <- fit_result$mu[1]
print(mean_mode1)
## [1] 0.4333947
variance_mode1 <- fit_result$sigma[1]^2
mean_mode2 <- fit_result$mu[2]
print(mean_mode2)
## [1] 0.6992993
variance_mode2 <- fit_result$sigma[2]^2
# Outlier detection
# Calculate lower and upper bounds for 0.001 probability limits
lower_limit_c <- qnorm(0.001, mean_mode1, sqrt(variance_mode1))
print(lower_limit_c)
## [1] 0.2580832
upper_limit_c <- qnorm(0.999, mean_mode2, sqrt(variance_mode2))
print(upper_limit_c)
## [1] 0.9640072
for(j in 1:512){
for(i in 1:length(img[,j])){
# Paint black outliers
if(column_img[i,j] > upper_limit_c | column_img[i,j] < lower_limit_c){
column_img[i,j] = 0
}
}
}
par(mfrow = c(1,2))
# Plotting Images
plot(NA,xlim=c(0,nrow(img)),ylim=c(0,ncol(img)),xlab="Horizontal",ylab="Vertical")
rasterImage(img,0,0,nrow(img),ncol(img))
plot(NA,xlim=c(0,nrow(column_img)),ylim=c(0,ncol(column_img)),xlab="Horizontal",ylab="Vertical")
rasterImage(column_img,0,0,nrow(column_img),ncol(column_img))
Although some of the linen errors are detected, the total accuracy is far beyond from sufficient. Therefore this model does not hold for this case as well.
The spatial data control procedure is designed to address the inherent 2D nature of image data, acknowledging that neighboring pixel values in an image may exhibit spatial relationships. This novel approach utilizes a statistic to identify regions of the image that may indicate irregularities or defects. When we work on an image which has a texture, the pixel values are related to the surrounding pixels in its neighborhood region. Hence detecting patches that center pixel is not significantly related to its neighborhood pixels in a standard regression function is a valid method to identify the regions of the image that might be problematic.
Procedure:
Feature Extraction:
The proposed method starts by extracting features from 3x3 blocks within the image, excluding the center pixel. This process is designed to capture the local context around each pixel.
Model Training:
A linear regression model is trained using the extracted features to understand the relationships between the center pixel and its surrounding context.
| x1 | x2 | x3 |
| x4 | y | x5 |
| x6 | x7 | x8 |
y is the center of the 3x3 patch and it is the response variable in the regression model. xi s are the predictor variables.
Residual Analysis:
Residuals are calculated to identify deviations between the predicted and actual center pixel values.
Control Limits:
Control limits are established based on the distribution of residuals.
upper_limit <- mean_residuals + 3sd_residuals lower_limit <- mean_residuals - 3sd_residuals
Patches with residuals beyond these limits are flagged as potentially defective.
Defect Identification:
Patches with residuals outside the control limits are identified and subsequently marked for further processing.
Image Modification:
The identified patches with potential defects are deleted from the original image and modified image is displayed.
library(jpeg)
library(MASS)
library(mixtools)
library(magick)
## Linking to ImageMagick 6.9.12.93
## Enabled features: cairo, fontconfig, freetype, heic, lcms, pango, raw, rsvg, webp
## Disabled features: fftw, ghostscript, x11
# Read the image
input_image_path <- "~/Desktop/Dersler/IE423/rawimage/0115.jpg" # Replace with your image file path
output_image_path <- "~/Desktop/Dersler/IE423/0115.jpg" # Replace with the desired output file path
# Read the input image
input_image <- image_read(input_image_path)
# Convert the image to grayscale
grayscale_image <- image_convert(input_image, colorspace = "gray")
# Write the grayscale image to the output path
image_write(grayscale_image, path = output_image_path)
img<- readJPEG("~/Desktop/Dersler/IE423/outputimage.jpg")
# Our Proposal
# Function to extract features from a 3x3 block (excluding center pixel)
extract_features <- function(block) {
center_pixel <- block[2, 2]
predictor_variables <- as.vector(block) # Flatten the block into a vector
predictor_variables <- predictor_variables[predictor_variables != center_pixel] # Exclude the center pixel
return(data.frame(center_pixel = center_pixel, predictor1 = predictor_variables[1], predictor2 =predictor_variables[2],
predictor3 = predictor_variables[3], predictor4 =predictor_variables[4],
predictor5 = predictor_variables[5], predictor6 =predictor_variables[6],
predictor7 = predictor_variables[7], predictor8 =predictor_variables[8]))
}
# Function to calculate residuals and append to the list
check_residuals <- function(model, data) {
y <- data$center_pixel
X <- data[-1] # Exclude the response variable
residuals <- y - predict(model, newdata = X)
return(residuals)
}
# You can set your own control limits based on your criteria
# Extract non-overlapping 3x3 blocks and extract features
blocks <- lapply(seq(1, nrow(img) - 2, by = 3), function(i) {
lapply(seq(1, ncol(img) - 2, by = 3), function(j) {
extract_features(img[i:(i+2), j:(j+2)])
})
})
# Flatten the list structure
flat_blocks <- unlist(blocks, recursive = FALSE)
# Create a data frame for training the model
train_data <- do.call(rbind, flat_blocks)
# Train a linear regression model
model <- lm(center_pixel ~ predictor1 + predictor2 + predictor3 + predictor4 +
predictor5 + predictor6 + predictor7 + predictor8, data = train_data)
# Check residuals and control limits for each block
residuals_list <- lapply(flat_blocks, function(block) {
check_residuals(model, block)
})
# Extract numeric values from the residuals_list
numeric_residuals <- sapply(residuals_list, function(residual) {
as.numeric(residual)
})
# Calculate the mean of the residuals
mean_residuals <- mean(numeric_residuals, na.rm = TRUE)
sd_residuals <-sd(numeric_residuals, na.rm = TRUE)
upper_limit <- mean_residuals + 3*sd_residuals
lower_limit <- mean_residuals - 3*sd_residuals
# Identify and remove patches with residuals outside control limits
out_of_limits_indices <- which(sapply(residuals_list, function(residuals) {
any(residuals > upper_limit | residuals < lower_limit)
}))
filtered_img <- img
for (index in out_of_limits_indices) {
i <- (index - 1) %/% (nrow(img)/3) * 3 + 1
j <- (index - 1) %% (ncol(img)/3) * 3 + 1
filtered_img[i:(i+2), j:(j+2)] <- 0
}
# Display the original and new images in a plot
par(mfrow=c(1,2))
# Original Image
plot(1, type='n', xlab='', ylab='', xlim=c(0, 512), ylim=c(0, 512))
rasterImage(img, 0, 0, 512, 512)
# Add titles to the plots
title(main="Original Image", xlab = "Pixel Value", ylab = "Frequency", line = 0.2)
# Filtered Image
plot(1, type='n', xlab='', ylab='', xlim=c(0, 512), ylim=c(0, 512))
rasterImage(filtered_img, 0, 0, 512, 512)
title(main="Filtered Image", xlab = "Pixel Value", ylab = "Frequency", line = 0.2)
5 images are randomly selected to evaluate “our proposal” on alternative images.
# First sample
# Read the image
input_image_path <-"~/Desktop/Dersler/IE423/rawimage/0075.jpg" # Replace with your image file path
output_image_path <- "~/Desktop/Dersler/IE423/new0075.jpg" # Replace with the desired output file path
# Read the input image
input_image <- image_read(input_image_path)
# Convert the image to grayscale
grayscale_image <- image_convert(input_image, colorspace = "gray")
# Write the grayscale image to the output path
image_write(grayscale_image, path = output_image_path)
image_path1<- readJPEG("~/Desktop/Dersler/IE423/new0075.jpg")
# Function to extract features from a 3x3 block (excluding center pixel)
extract_features <- function(block) {
center_pixel <- block[2, 2]
predictor_variables <- as.vector(block) # Flatten the block into a vector
predictor_variables <- predictor_variables[predictor_variables != center_pixel] # Exclude the center pixel
return(data.frame(center_pixel = center_pixel, predictor1 = predictor_variables[1], predictor2 =predictor_variables[2],
predictor3 = predictor_variables[3], predictor4 =predictor_variables[4],
predictor5 = predictor_variables[5], predictor6 =predictor_variables[6],
predictor7 = predictor_variables[7], predictor8 =predictor_variables[8]))
}
# Function to calculate residuals and append to the list
check_residuals <- function(model, data) {
y <- data$center_pixel
X <- data[-1] # Exclude the response variable
residuals <- y - predict(model, newdata = X)
return(residuals)
}
# You can set your own control limits based on your criteria
# Extract non-overlapping 3x3 blocks and extract features
blocks <- lapply(seq(1, nrow(image_path1) - 2, by = 3), function(i) {
lapply(seq(1, ncol(image_path1) - 2, by = 3), function(j) {
extract_features(image_path1[i:(i+2), j:(j+2)])
})
})
# Flatten the list structure
flat_blocks <- unlist(blocks, recursive = FALSE)
# Create a data frame for training the model
train_data <- do.call(rbind, flat_blocks)
# Train a linear regression model
model <- lm(center_pixel ~ predictor1 + predictor2 + predictor3 + predictor4 +
predictor5 + predictor6 + predictor7 + predictor8, data = train_data)
# Check residuals and control limits for each block
residuals_list <- lapply(flat_blocks, function(block) {
check_residuals(model, block)
})
# Extract numeric values from the residuals_list
numeric_residuals <- sapply(residuals_list, function(residual) {
as.numeric(residual)
})
# Calculate the mean of the residuals
mean_residuals <- mean(numeric_residuals, na.rm = TRUE)
sd_residuals <-sd(numeric_residuals, na.rm = TRUE)
upper_limit <- mean_residuals + 3*sd_residuals
lower_limit <- mean_residuals - 3*sd_residuals
# Identify and remove patches with residuals outside control limits
out_of_limits_indices <- which(sapply(residuals_list, function(residuals) {
any(residuals > upper_limit | residuals < lower_limit)
}))
filtered_image1 <- image_path1
for (index in out_of_limits_indices) {
i <- (index - 1) %/% (nrow(image_path1)/3) * 3 + 1
j <- (index - 1) %% (ncol(image_path1)/3) * 3 + 1
filtered_image1[i:(i+2), j:(j+2)] <- 0
}
# Display the original and new images in a plot
par(mfrow=c(1,2))
# Original Image
plot(1, type='n', xlab='', ylab='', xlim=c(0, 512), ylim=c(0, 512))
rasterImage(image_path1, 0, 0, 512, 512)
title(main="Original Image", xlab = "Pixel Value", ylab = "Frequency", line = 0.2)
# Filtered Image
plot(1, type='n', xlab='', ylab='', xlim=c(0, 512), ylim=c(0, 512))
rasterImage(filtered_image1, 0, 0, 512, 512)
title(main="Filtered Image_Path1", xlab = "Pixel Value", ylab = "Frequency", line = 0.2)
# Second Sample
# Read the image
input_image_path <-"~/Desktop/Dersler/IE423/rawimage/0054.jpg" # Replace with your image file path
output_image_path <- "~/Desktop/Dersler/IE423/new0054.jpg" # Replace with the desired output file path
# Read the input image
input_image <- image_read(input_image_path)
# Convert the image to grayscale
grayscale_image <- image_convert(input_image, colorspace = "gray")
# Write the grayscale image to the output path
image_write(grayscale_image, path = output_image_path)
image_path2<- readJPEG("~/Desktop/Dersler/IE423/new0054.jpg")
# Function to extract features from a 3x3 block (excluding center pixel)
extract_features <- function(block) {
center_pixel <- block[2, 2]
predictor_variables <- as.vector(block) # Flatten the block into a vector
predictor_variables <- predictor_variables[predictor_variables != center_pixel] # Exclude the center pixel
return(data.frame(center_pixel = center_pixel, predictor1 = predictor_variables[1], predictor2 =predictor_variables[2],
predictor3 = predictor_variables[3], predictor4 =predictor_variables[4],
predictor5 = predictor_variables[5], predictor6 =predictor_variables[6],
predictor7 = predictor_variables[7], predictor8 =predictor_variables[8]))
}
# Function to calculate residuals and append to the list
check_residuals <- function(model, data) {
y <- data$center_pixel
X <- data[-1] # Exclude the response variable
residuals <- y - predict(model, newdata = X)
return(residuals)
}
# You can set your own control limits based on your criteria
# Extract non-overlapping 3x3 blocks and extract features
blocks <- lapply(seq(1, nrow(image_path2) - 2, by = 3), function(i) {
lapply(seq(1, ncol(image_path2) - 2, by = 3), function(j) {
extract_features(image_path2[i:(i+2), j:(j+2)])
})
})
# Flatten the list structure
flat_blocks <- unlist(blocks, recursive = FALSE)
# Create a data frame for training the model
train_data <- do.call(rbind, flat_blocks)
# Train a linear regression model
model <- lm(center_pixel ~ predictor1 + predictor2 + predictor3 + predictor4 +
predictor5 + predictor6 + predictor7 + predictor8, data = train_data)
# Check residuals and control limits for each block
residuals_list <- lapply(flat_blocks, function(block) {
check_residuals(model, block)
})
# Extract numeric values from the residuals_list
numeric_residuals <- sapply(residuals_list, function(residual) {
as.numeric(residual)
})
# Calculate the mean of the residuals
mean_residuals <- mean(numeric_residuals, na.rm = TRUE)
sd_residuals <-sd(numeric_residuals, na.rm = TRUE)
upper_limit <- mean_residuals + 3*sd_residuals
lower_limit <- mean_residuals - 3*sd_residuals
# Identify and remove patches with residuals outside control limits
out_of_limits_indices <- which(sapply(residuals_list, function(residuals) {
any(residuals > upper_limit | residuals < lower_limit)
}))
filtered_image2 <- image_path2
for (index in out_of_limits_indices) {
i <- (index - 1) %/% (nrow(image_path2)/3) * 3 + 1
j <- (index - 1) %% (ncol(image_path2)/3) * 3 + 1
filtered_image2[i:(i+2), j:(j+2)] <- 0
}
# Display the original and new images in a plot
par(mfrow=c(1,2))
# Original Image
plot(1, type='n', xlab='', ylab='', xlim=c(0, 512), ylim=c(0, 512))
rasterImage(image_path2, 0, 0, 512, 512)
title(main="Original Image", xlab = "Pixel Value", ylab = "Frequency", line = 0.2)
# Filtered Image
plot(1, type='n', xlab='', ylab='', xlim=c(0, 512), ylim=c(0, 512))
rasterImage(filtered_image2, 0, 0, 512, 512)
title(main="Filtered Image_Path2", xlab = "Pixel Value", ylab = "Frequency", line = 0.2)
# Third Sample
# Read the image
input_image_path <-"~/Desktop/Dersler/IE423/rawimage/0163.jpg" # Replace with your image file path
output_image_path <- "~/Desktop/Dersler/IE423/new0163.jpg" # Replace with the desired output file path
# Read the input image
input_image <- image_read(input_image_path)
# Convert the image to grayscale
grayscale_image <- image_convert(input_image, colorspace = "gray")
# Write the grayscale image to the output path
image_write(grayscale_image, path = output_image_path)
image_path3<- readJPEG("~/Desktop/Dersler/IE423/new0163.jpg")
# Function to extract features from a 3x3 block (excluding center pixel)
extract_features <- function(block) {
center_pixel <- block[2, 2]
predictor_variables <- as.vector(block) # Flatten the block into a vector
predictor_variables <- predictor_variables[predictor_variables != center_pixel] # Exclude the center pixel
return(data.frame(center_pixel = center_pixel, predictor1 = predictor_variables[1], predictor2 =predictor_variables[2],
predictor3 = predictor_variables[3], predictor4 =predictor_variables[4],
predictor5 = predictor_variables[5], predictor6 =predictor_variables[6],
predictor7 = predictor_variables[7], predictor8 =predictor_variables[8]))
}
# Function to calculate residuals and append to the list
check_residuals <- function(model, data) {
y <- data$center_pixel
X <- data[-1] # Exclude the response variable
residuals <- y - predict(model, newdata = X)
return(residuals)
}
# You can set your own control limits based on your criteria
# Extract non-overlapping 3x3 blocks and extract features
blocks <- lapply(seq(1, nrow(image_path3) - 2, by = 3), function(i) {
lapply(seq(1, ncol(image_path3) - 2, by = 3), function(j) {
extract_features(image_path3[i:(i+2), j:(j+2)])
})
})
# Flatten the list structure
flat_blocks <- unlist(blocks, recursive = FALSE)
# Create a data frame for training the model
train_data <- do.call(rbind, flat_blocks)
# Train a linear regression model
model <- lm(center_pixel ~ predictor1 + predictor2 + predictor3 + predictor4 +
predictor5 + predictor6 + predictor7 + predictor8, data = train_data)
# Check residuals and control limits for each block
residuals_list <- lapply(flat_blocks, function(block) {
check_residuals(model, block)
})
# Extract numeric values from the residuals_list
numeric_residuals <- sapply(residuals_list, function(residual) {
as.numeric(residual)
})
# Calculate the mean of the residuals
mean_residuals <- mean(numeric_residuals, na.rm = TRUE)
sd_residuals <-sd(numeric_residuals, na.rm = TRUE)
upper_limit <- mean_residuals + 3*sd_residuals
lower_limit <- mean_residuals - 3*sd_residuals
# Identify and remove patches with residuals outside control limits
out_of_limits_indices <- which(sapply(residuals_list, function(residuals) {
any(residuals > upper_limit | residuals < lower_limit)
}))
filtered_image3 <- image_path3
for (index in out_of_limits_indices) {
i <- (index - 1) %/% (nrow(image_path3)/3) * 3 + 1
j <- (index - 1) %% (ncol(image_path3)/3) * 3 + 1
filtered_image3[i:(i+2), j:(j+2)] <- 0
}
# Display the original and new images in a plot
par(mfrow=c(1,2))
# Original Image
plot(1, type='n', xlab='', ylab='', xlim=c(0, 512), ylim=c(0, 512))
rasterImage(image_path3, 0, 0, 512, 512)
title(main="Original Image", xlab = "Pixel Value", ylab = "Frequency", line = 0.2)
# Filtered Image
plot(1, type='n', xlab='', ylab='', xlim=c(0, 512), ylim=c(0, 512))
rasterImage(filtered_image3, 0, 0, 512, 512)
title(main="Filtered Image_Path3", xlab = "Pixel Value", ylab = "Frequency", line = 0.2)
# Forth Sample
# Read the image
input_image_path <-"~/Desktop/Dersler/IE423/rawimage/0073.jpg" # Replace with your image file path
output_image_path <- "~/Desktop/Dersler/IE423/new0073.jpg" # Replace with the desired output file path
# Read the input image
input_image <- image_read(input_image_path)
# Convert the image to grayscale
grayscale_image <- image_convert(input_image, colorspace = "gray")
# Write the grayscale image to the output path
image_write(grayscale_image, path = output_image_path)
image_path4<- readJPEG("~/Desktop/Dersler/IE423/new0073.jpg")
# Function to extract features from a 3x3 block (excluding center pixel)
extract_features <- function(block) {
center_pixel <- block[2, 2]
predictor_variables <- as.vector(block) # Flatten the block into a vector
predictor_variables <- predictor_variables[predictor_variables != center_pixel] # Exclude the center pixel
return(data.frame(center_pixel = center_pixel, predictor1 = predictor_variables[1], predictor2 =predictor_variables[2],
predictor3 = predictor_variables[3], predictor4 =predictor_variables[4],
predictor5 = predictor_variables[5], predictor6 =predictor_variables[6],
predictor7 = predictor_variables[7], predictor8 =predictor_variables[8]))
}
# Function to calculate residuals and append to the list
check_residuals <- function(model, data) {
y <- data$center_pixel
X <- data[-1] # Exclude the response variable
residuals <- y - predict(model, newdata = X)
return(residuals)
}
# You can set your own control limits based on your criteria
# Extract non-overlapping 3x3 blocks and extract features
blocks <- lapply(seq(1, nrow(image_path4) - 2, by = 3), function(i) {
lapply(seq(1, ncol(image_path4) - 2, by = 3), function(j) {
extract_features(image_path4[i:(i+2), j:(j+2)])
})
})
# Flatten the list structure
flat_blocks <- unlist(blocks, recursive = FALSE)
# Create a data frame for training the model
train_data <- do.call(rbind, flat_blocks)
# Train a linear regression model
model <- lm(center_pixel ~ predictor1 + predictor2 + predictor3 + predictor4 +
predictor5 + predictor6 + predictor7 + predictor8, data = train_data)
# Check residuals and control limits for each block
residuals_list <- lapply(flat_blocks, function(block) {
check_residuals(model, block)
})
# Extract numeric values from the residuals_list
numeric_residuals <- sapply(residuals_list, function(residual) {
as.numeric(residual)
})
# Calculate the mean of the residuals
mean_residuals <- mean(numeric_residuals, na.rm = TRUE)
sd_residuals <-sd(numeric_residuals, na.rm = TRUE)
upper_limit <- mean_residuals + 3*sd_residuals
lower_limit <- mean_residuals - 3*sd_residuals
# Identify and remove patches with residuals outside control limits
out_of_limits_indices <- which(sapply(residuals_list, function(residuals) {
any(residuals > upper_limit | residuals < lower_limit)
}))
filtered_image4 <- image_path4
for (index in out_of_limits_indices) {
i <- (index - 1) %/% (nrow(image_path4)/3) * 3 + 1
j <- (index - 1) %% (ncol(image_path4)/3) * 3 + 1
filtered_image4[i:(i+2), j:(j+2)] <- 0
}
# Display the original and new images in a plot
par(mfrow=c(1,2))
# Original Image
plot(1, type='n', xlab='', ylab='', xlim=c(0, 512), ylim=c(0, 512))
rasterImage(image_path4, 0, 0, 512, 512)
title(main="Original Image", xlab = "Pixel Value", ylab = "Frequency", line = 0.2)
# Filtered Image
plot(1, type='n', xlab='', ylab='', xlim=c(0, 512), ylim=c(0, 512))
rasterImage(filtered_image4, 0, 0, 512, 512)
title(main="Filtered Image_Path4", xlab = "Pixel Value", ylab = "Frequency", line = 0.2)
# Fifth Sample
# Read the image
input_image_path <-"~/Desktop/Dersler/IE423/rawimage/0118.jpg" # Replace with your image file path
output_image_path <- "~/Desktop/Dersler/IE423/new0118.jpg" # Replace with the desired output file path
# Read the input image
input_image <- image_read(input_image_path)
# Convert the image to grayscale
grayscale_image <- image_convert(input_image, colorspace = "gray")
# Write the grayscale image to the output path
image_write(grayscale_image, path = output_image_path)
image_path5<- readJPEG("~/Desktop/Dersler/IE423/new0118.jpg")
# Function to extract features from a 3x3 block (excluding center pixel)
extract_features <- function(block) {
center_pixel <- block[2, 2]
predictor_variables <- as.vector(block) # Flatten the block into a vector
predictor_variables <- predictor_variables[predictor_variables != center_pixel] # Exclude the center pixel
return(data.frame(center_pixel = center_pixel, predictor1 = predictor_variables[1], predictor2 =predictor_variables[2],
predictor3 = predictor_variables[3], predictor4 =predictor_variables[4],
predictor5 = predictor_variables[5], predictor6 =predictor_variables[6],
predictor7 = predictor_variables[7], predictor8 =predictor_variables[8]))
}
# Function to calculate residuals and append to the list
check_residuals <- function(model, data) {
y <- data$center_pixel
X <- data[-1] # Exclude the response variable
residuals <- y - predict(model, newdata = X)
return(residuals)
}
# You can set your own control limits based on your criteria
# Extract non-overlapping 3x3 blocks and extract features
blocks <- lapply(seq(1, nrow(image_path5) - 2, by = 3), function(i) {
lapply(seq(1, ncol(image_path5) - 2, by = 3), function(j) {
extract_features(image_path5[i:(i+2), j:(j+2)])
})
})
# Flatten the list structure
flat_blocks <- unlist(blocks, recursive = FALSE)
# Create a data frame for training the model
train_data <- do.call(rbind, flat_blocks)
# Train a linear regression model
model <- lm(center_pixel ~ predictor1 + predictor2 + predictor3 + predictor4 +
predictor5 + predictor6 + predictor7 + predictor8, data = train_data)
# Check residuals and control limits for each block
residuals_list <- lapply(flat_blocks, function(block) {
check_residuals(model, block)
})
# Extract numeric values from the residuals_list
numeric_residuals <- sapply(residuals_list, function(residual) {
as.numeric(residual)
})
# Calculate the mean of the residuals
mean_residuals <- mean(numeric_residuals, na.rm = TRUE)
sd_residuals <-sd(numeric_residuals, na.rm = TRUE)
upper_limit <- mean_residuals + 3*sd_residuals
lower_limit <- mean_residuals - 3*sd_residuals
# Identify and remove patches with residuals outside control limits
out_of_limits_indices <- which(sapply(residuals_list, function(residuals) {
any(residuals > upper_limit | residuals < lower_limit)
}))
filtered_image5 <- image_path5
for (index in out_of_limits_indices) {
i <- (index - 1) %/% (nrow(image_path5)/3) * 3 + 1
j <- (index - 1) %% (ncol(image_path5)/3) * 3 + 1
filtered_image5[i:(i+2), j:(j+2)] <- 0
}
# Display the original and new images in a plot
par(mfrow=c(1,2))
# Original Image
plot(1, type='n', xlab='', ylab='', xlim=c(0, 512), ylim=c(0, 512))
rasterImage(image_path5, 0, 0, 512, 512)
title(main="Original Image", xlab = "Pixel Value", ylab = "Frequency", line = 0.2)
# Filtered Image
plot(1, type='n', xlab='', ylab='', xlim=c(0, 512), ylim=c(0, 512))
rasterImage(filtered_image5, 0, 0, 512, 512)
title(main="Filtered Image_Path5", xlab = "Pixel Value", ylab = "Frequency", line = 0.2)
1. A Baseline Defect Detection Approach from a Statistical Data Analysis Perspective:
Purpose: -Identify the underlying bimodal distribution in the pixel values of the entire image. -Understand the statistical characteristics of the image data.
Implications: -Provides a global perspective on the distribution of pixel values. -Assumes that the entire image can be accurately represented by a bimodal distribution.
2. A Baseline Defect Detection Approach from a Statistical Data Analysis Perspective in 51x51 Patches:
Purpose: -Analyze local variations in pixel values within smaller patches (51x51). -Apply bimodal distribution fitting to each patch independently.
Implications: -Captures local characteristics and variations within the image. -Allows for more nuanced analysis compared to a global approach. -Assumes that local regions may exhibit different statistical properties.
3. Simple Defect Detection Approach from a Control Chart Perspective
Purpose: -Detect outliers along rows and columns in the image. -Apply statistical process control principles to identify abnormal patterns.
Implications: -Focuses on identifying outliers and patterns that may not be captured by a global or local distribution fitting approach. -Can reveal systematic anomalies or artifacts that occur along rows or columns.
4. Our Approach
Purpose: The purpose of the proposed spatial data control procedure is to develop a robust method for defect identification in images, particularly addressing the inherent 2D nature of image data. By acknowledging the spatial relationships among neighboring pixels, the procedure aims to detect irregularities or defects in image regions where pixel values exhibit significant deviations from their surrounding context. This approach utilizes statistical methods, specifically linear regression modeling, to understand and quantify the relationships between the center pixel and its neighboring pixels in local patches. The overarching goal is to provide a systematic and efficient way to identify and potentially rectify defective regions within an image.
Implications: -Improved Defect Detection: The proposed procedure leverages spatial information to enhance defect detection. This could lead to improved accuracy in identifying problematic regions within an image compared to traditional methods that may not consider local relationships. -Adaptability to Various Textures: As the method focuses on local context and does not rely on pre-defined defect patterns, it may be adaptable to various textures and types of images. This flexibility makes it potentially applicable to a wide range of industries and domains. -Quantitative Assessment of Defects: The use of linear regression allows for a quantitative assessment of the relationships between pixels. This not only aids in identifying defects but also provides a measure of how much the center pixel deviates from what is expected based on its local context.